]> err.no Git - dak/commitdiff
moved inserts of known_changes to Changes() class. add insert known_changes in p...
authorMike O'Connor <stew@vireo.org>
Thu, 29 Oct 2009 21:08:56 +0000 (22:08 +0100)
committerMike O'Connor <stew@vireo.org>
Thu, 29 Oct 2009 21:08:56 +0000 (22:08 +0100)
Signed-off-by: Mike O'Connor <stew@vireo.org>
dak/dakdb/update20.py
dak/process_new.py
dak/process_unchecked.py
daklib/changes.py

index a666326cb3acb986891bcfee87c686b966d0d437..fcb7820945571b1490c9c8d30804ca88d74942ce 100755 (executable)
@@ -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()
index 9a6c8e330f787b7828a5ee14e8db8a21064c4e58..ad67dc5c43970ca3dfa94d9e960528ad8c2e35fd 100755 (executable)
@@ -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
index db29ac42a1a1220ddf9e30e332861049c42a5cac..886fb68948ab6d365b64976dd3ff6588cb82291e 100755 (executable)
@@ -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':
index ff23222486a220a3fd8d316836b01c51ff5db55a..0fc21cb39d59b5f1326d0fdedc2be8570b4979c6 100755 (executable)
@@ -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):
         """