From: Mike O'Connor Date: Thu, 29 Oct 2009 21:08:56 +0000 (+0100) Subject: moved inserts of known_changes to Changes() class. add insert known_changes in p... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0d2550d84696caafb8e850aec533108f792ff41;p=dak moved inserts of known_changes to Changes() class. add insert known_changes in p-u, remove known_changes in process_new.reject Signed-off-by: Mike O'Connor --- diff --git a/dak/dakdb/update20.py b/dak/dakdb/update20.py index a666326c..fcb78209 100755 --- a/dak/dakdb/update20.py +++ b/dak/dakdb/update20.py @@ -105,6 +105,7 @@ def do_update(self): distribution TEXT NOT NULL, urgency TEXT NOT NULL, maintainer TEXT NOT NULL, + fingerprint TEXT NOT NULL, changedby TEXT NOT NULL, date TEXT NOT NULL, UNIQUE (changesname) @@ -135,8 +136,10 @@ def do_update(self): try: count += 1 print "Directory %s, file %7d, failures %3d. (%s)" % (dirpath[-10:], count, failure, changesfile) - changes = parse_changes(os.path.join(dirpath, changesfile), signing_rules=-1) - (changes["fingerprint"], _) = check_signature(os.path.join(dirpath, changesfile)) + changes = Changes() + changesfile = os.path.join(dirpath, changesfile) + changes.changes = parse_changes(changesfile, signing_rules=-1) + (changes.changes["fingerprint"], _) = check_signature(changesfile)) except InvalidDscError, line: warn("syntax error in .dsc file '%s', line %s." % (f, line)) failure += 1 @@ -144,8 +147,10 @@ def do_update(self): warn("found invalid changes file, not properly utf-8 encoded") failure += 1 - filetime = datetime.datetime.fromtimestamp(os.path.getctime(os.path.join(dirpath, changesfile))) - c.execute("INSERT INTO known_changes(changesname, seen, source, binaries, architecture, version, distribution, urgency, maintainer, changedby, date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" , [changesfile, filetime, changes["source"], changes["binary"], changes["architecture"], changes["version"], changes["distribution"], changes["urgency"], changes["maintainer"], changes["changed-by"], changes["date"]]) + changes.add_known_changes(directory) + + c.execute("GRANT ALL ON known_changes TO ftpmaster;") + c.execute("GRANT SELECT ON known_changes TO public;") c.execute("UPDATE config SET value = '20' WHERE name = 'db_revision'") self.db.commit() diff --git a/dak/process_new.py b/dak/process_new.py index 9a6c8e33..ad67dc5c 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -800,6 +800,7 @@ def do_byhand(upload, session): Logger.log(["BYHAND REJECT: %s" % (upload.pkg.changes_file)]) upload.do_reject(manual=1, reject_message=Options["Manual-Reject"]) os.unlink(upload.pkg.changes_file[:-8]+".dak") + upload.pkg.remove_known_changes() done = 1 elif answer == 'S': done = 1 diff --git a/dak/process_unchecked.py b/dak/process_unchecked.py index db29ac42..886fb689 100755 --- a/dak/process_unchecked.py +++ b/dak/process_unchecked.py @@ -191,10 +191,12 @@ def action(u): os.chdir(u.pkg.directory) u.do_reject(0, pi) elif answer == 'A': + u.pkg.add_known_changes( "Accepted" ) u.accept(summary, short_summary) u.check_override() u.remove() elif answer == queuekey: + u.pkg.add_known_changes( qu ) queue_info[qu]["process"](u, summary, short_summary) u.remove() elif answer == 'Q': diff --git a/daklib/changes.py b/daklib/changes.py index ff232224..0fc21cb3 100755 --- a/daklib/changes.py +++ b/daklib/changes.py @@ -173,6 +173,49 @@ class Changes(object): return summary + def remove_known_changes(self, session=None): + if session is None: + session = DBConn().session() + privatetrans = True + + session.query(KnownChange).filter(changesfile=self.changes_file).delete() + + if privatetrans: + session.commit() + session.close() + def add_known_changes(self, queue, session=None): + cnf = Config() + + if session is None: + session = DBConn().session() + privatetrans = True + + dirpath = cnf["Dir::Queue::%s" % (queue) ] + changesfile = os.path.join(dirpath, self.changes_file) + filetime = datetime.datetime.fromtimestamp(os.path.getctime(changesfile)) + + session.execute( + """INSERT INTO known_changes + (changesname, seen, source, binaries, architecture, version, + distribution, urgency, maintainer, fingerprint, changedby, date) + VALUES (:changesfile,:filetime,:source,:binary, :architecture, + :version,:distribution,:urgency,'maintainer,:changedby,:date)""", + { 'changesfile':changesfile, + 'filetime':filetime, + 'source':self.changes["source"], + 'binary':self.changes["binary"], + 'architecture':self.changes["architecture"], + 'version':self.changes["version"], + 'distribution':self.changes["distribution"], + 'urgency':self.changes["urgency"], + 'maintainer':self.changes["maintainer"], + 'fingerprint':self.changes["fingerprint"], + 'changedby':self.changes["changed-by"], + 'date':self.changes["date"]} ) + + if privatetrans: + session.commit() + session.close() def load_dot_dak(self, changesfile): """