log.log(['unexpected filename', basename])
continue
+ with open(fn, 'r') as fh:
+ data = fh.read()
+
try:
- command = CommandFile(fn, log)
+ command = CommandFile(basename, data, log)
command.evaluate()
except:
created = os.stat(fn).st_mtime
dst = find_next_free(os.path.join(donedir, basename))
with FilesystemTransaction() as fs:
- fs.move(fn, dst, mode=0o644)
+ fs.unlink(fn)
+ fs.create(dst, mode=0o644).write(data)
fs.commit()
log.close()
pass
class CommandFile(object):
- def __init__(self, path, log=None):
+ def __init__(self, filename, data, log=None):
if log is None:
from daklib.daklog import Logger
log = Logger()
self.cc = []
self.result = []
self.log = log
- self.path = path
- self.filename = os.path.basename(path)
+ self.filename = filename
+ self.data = data
def _check_replay(self, signed_file, session):
"""check for replays
keyrings = session.query(Keyring).filter_by(active=True).order_by(Keyring.priority)
keyring_files = [ k.keyring_name for k in keyrings ]
- raw_contents = open(self.path, 'r').read()
- signed_file = SignedFile(raw_contents, keyring_files)
+ signed_file = SignedFile(self.data, keyring_files)
if not signed_file.valid:
self.log.log(['invalid signature', self.filename])
return False