IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Bläddra i källkod

Started working on step hashes.

tags/0.92
förälder
incheckning
e91fa97fbb
3 ändrade filer med 61 tillägg och 0 borttagningar
  1. +15
    -0
      focker-compose.yml
  2. +0
    -0
      hash.py
  3. +46
    -0
      steps.py

+ 15
- 0
focker-compose.yml Visa fil

@@ -0,0 +1,15 @@
defaults:
jail:
mount.devfs: true
interface: lo1
exec.start: /bin/sh /etc/rc
exec.stop: /bin/sh /etc/rc.shutdown
services:
gateway:
image: freebsd-12.1
jail:
ip4.address: 127.0.0.2
volumes:
gateway-data: {}

+ 0
- 0
hash.py Visa fil


+ 46
- 0
steps.py Visa fil

@@ -0,0 +1,46 @@
import hashlib
import json
def filehash(fname):
h = hashlib.sha256()
with open(fname, 'rb') as f:
while True:
data = f.read(1024*1024*4)
if not data:
break
h.update(data)
res = h.hexdigest()
return res
class RunStep(object):
def __init__(self, base, spec):
self.base = base
self.spec = spec
def hash(self):
res = hashlib.sha256(
json.dumps(( self.base, self.spec ))
.encode('utf-8')).hexdigest()
return res
class CopyStep(object):
def __init__(self, base, spec):
if not isinstance(spec, list):
raise ValueError('CopyStep spec should be a list')
self.base = base
self.spec = spec
def hash(self):
if len(self.spec) == 0:
fh = []
elif isinstance(self.spec[0], list):
fh = list(map(lambda a: filehash(a[0]), self.spec))
else:
fh = [ filehash(self.spec[0]) ]
res = hashlib.sha256(
json.dumps(( self.base, fh, self.spec ))
.encode('utf-8')).hexdigest()
return res

Laddar…
Avbryt
Spara