X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fprocess_commands.py;h=c679d9c2422acb04582a7fef3d309468c7566216;hb=245c6549dbacaeab5ee36ec74372b1df8675b477;hp=7e013dcd0b93dbdff882cbf9db84235be5514863;hpb=44ad10099864ca7a124f7baab6524ec10ec88e54;p=dak.git diff --git a/dak/process_commands.py b/dak/process_commands.py index 7e013dcd..c679d9c2 100644 --- a/dak/process_commands.py +++ b/dak/process_commands.py @@ -20,11 +20,13 @@ import apt_pkg import datetime import os import sys +import time from daklib.config import Config from daklib.command import CommandError, CommandFile from daklib.daklog import Logger from daklib.fstransactions import FilesystemTransaction +from daklib.gpg import GpgException from daklib.utils import find_next_free def usage(): @@ -41,7 +43,7 @@ def main(argv=None): ('d', 'directory', 'Process-Commands::Options::Directory', 'HasArg')] cnf = Config() - cnf['Process-Command::Options::Dummy'] = '' + cnf['Process-Commands::Options::Dummy'] = '' filenames = apt_pkg.parse_commandline(cnf.Cnf, arguments, argv) options = cnf.subtree('Process-Commands::Options') @@ -64,16 +66,28 @@ def main(argv=None): log.log(['unexpected filename', basename]) continue - command = CommandFile(fn, log) - if command.evaluate(): - log.log(['moving to done', basename]) - dst = find_next_free(os.path.join(donedir, basename)) - else: - log.log(['moving to reject', basename]) + with open(fn, 'r') as fh: + data = fh.read() + + try: + command = CommandFile(basename, data, log) + command.evaluate() + except: + created = os.stat(fn).st_mtime + now = time.time() + too_new = (now - created < int(cnf.get('Dinstall::SkipTime', '60'))) + if too_new: + log.log(['skipped (too new)']) + continue + log.log(['reject', basename]) dst = find_next_free(os.path.join(rejectdir, basename)) + else: + log.log(['done', basename]) + 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()