X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=dak%2Fprocess_policy.py;h=2890c8615403b4017710e711194de46f7cda7f7b;hb=677e507613f0c410ffaefda67413ad82c2ed454c;hp=ab58cfe1dce84ce2cc990c01b7987c7636220f66;hpb=354d46ad379c4c4e167d0fa7cdf7f9c34f3afbcd;p=dak.git diff --git a/dak/process_policy.py b/dak/process_policy.py index ab58cfe1..2890c861 100755 --- a/dak/process_policy.py +++ b/dak/process_policy.py @@ -56,6 +56,7 @@ Logger = None def do_comments(dir, srcqueue, opref, npref, line, fn, transaction): session = transaction.session + actions = [] for comm in [ x for x in os.listdir(dir) if x.startswith(opref) ]: lines = open(os.path.join(dir, comm)).readlines() if len(lines) == 0 or lines[0] != line + "\n": continue @@ -75,13 +76,19 @@ def do_comments(dir, srcqueue, opref, npref, line, fn, transaction): uploads = session.query(PolicyQueueUpload).filter_by(policy_queue=srcqueue) \ .join(PolicyQueueUpload.changes).filter(DBChange.changesname.startswith(changes_prefix)) \ .order_by(PolicyQueueUpload.source_id) - for u in uploads: - print "Processing changes file: %s" % u.changes.changesname - fn(u, srcqueue, "".join(lines[1:]), transaction) + reason = "".join(lines[1:]) + actions.extend((u, reason) for u in uploads) if opref != npref: newcomm = npref + comm[len(opref):] - transaction.fs.move(os.path.join(dir, comm), os.path.join(dir, newcomm)) + newcomm = utils.find_next_free(os.path.join(dir, newcomm)) + transaction.fs.move(os.path.join(dir, comm), newcomm) + + actions.sort() + + for u, reason in actions: + print("Processing changes file: {0}".format(u.changes.changesname)) + fn(u, srcqueue, reason, transaction) ################################################################################ @@ -412,9 +419,9 @@ def main(): # The comments stuff relies on being in the right directory os.chdir(pq.path) + do_comments(commentsdir, pq, "REJECT.", "REJECTED.", "NOTOK", comment_reject, transaction) do_comments(commentsdir, pq, "ACCEPT.", "ACCEPTED.", "OK", comment_accept, transaction) do_comments(commentsdir, pq, "ACCEPTED.", "ACCEPTED.", "OK", comment_accept, transaction) - do_comments(commentsdir, pq, "REJECT.", "REJECTED.", "NOTOK", comment_reject, transaction) remove_unreferenced_binaries(pq, transaction) remove_unreferenced_sources(pq, transaction)