[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master 2/8] 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 <stew@vireo.org>
---
 dak/dakdb/update20.py    |   13 +++++++++----
 dak/process_new.py       |    1 +
 dak/process_unchecked.py |    2 ++
 daklib/changes.py        |   43 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/dak/dakdb/update20.py b/dak/dakdb/update20.py
index a666326..fcb7820 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 9a6c8e3..ad67dc5 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 db29ac4..886fb68 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 ff23222..0fc21cb 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):
         """
-- 
1.6.3.3



Reply to: