]> git.decadent.org.uk Git - dak.git/blobdiff - dak/process_upload.py
stop using deprecated python-apt functions
[dak.git] / dak / process_upload.py
index 22c333c9910a86cf8148492f28a18ea1c724a1e2..53ab7cc98f7be1553e050449c181e238c97a3275 100755 (executable)
@@ -229,7 +229,7 @@ def action(u, session):
 
     try:
         chg = session.query(DBChange).filter_by(changesname=os.path.basename(u.pkg.changes_file)).one()
-    except NoResultFound, e:
+    except NoResultFound as e:
         chg = None
 
     if len(u.rejects) > 0:
@@ -364,7 +364,7 @@ def process_it(changes_file, session):
         # If this is the Real Thing(tm), copy things into a private
         # holding directory first to avoid replacable file races.
         if not Options["No-Action"]:
-            os.chdir(cnf["Dir::Queue::Holding"])
+            holding.chdir_to_holding()
 
             # Absolutize the filename to avoid the requirement of being in the
             # same directory as the .changes file.
@@ -424,7 +424,6 @@ def main():
 
     cnf = Config()
     summarystats = SummaryStats()
-    log_urgency = False
 
     DBConn()
 
@@ -440,8 +439,8 @@ def main():
         if not cnf.has_key("Dinstall::Options::%s" % (i)):
             cnf["Dinstall::Options::%s" % (i)] = ""
 
-    changes_files = apt_pkg.ParseCommandLine(cnf.Cnf, Arguments, sys.argv)
-    Options = cnf.SubTree("Dinstall::Options")
+    changes_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv)
+    Options = cnf.subtree("Dinstall::Options")
 
     if Options["Help"]:
         usage()
@@ -456,20 +455,20 @@ def main():
 
     # Obtain lock if not in no-action mode and initialize the log
     if not Options["No-Action"]:
-        lock_fd = os.open(cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT)
+        lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'dinstall.lock'), os.O_RDWR | os.O_CREAT)
         try:
             fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
-        except IOError, e:
+        except IOError as e:
             if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
                 utils.fubar("Couldn't obtain lock; assuming another 'dak process-upload' is already running.")
             else:
                 raise
-        if cnf.get("Dir::UrgencyLog"):
-            # Initialise UrgencyLog()
-            log_urgency = True
-            UrgencyLog()
 
-    Logger = daklog.Logger(cnf, "process-upload", Options["No-Action"])
+        # Initialise UrgencyLog() - it will deal with the case where we don't
+        # want to log urgencies
+        urgencylog = UrgencyLog()
+
+    Logger = daklog.Logger("process-upload", Options["No-Action"])
 
     # If we have a directory flag, use it to find our files
     if cnf["Dinstall::Options::Directory"] != "":
@@ -503,11 +502,17 @@ def main():
                                                 utils.size_type(int(summarystats.accept_bytes)))
         Logger.log(["total", summarystats.accept_count, summarystats.accept_bytes])
 
+    if summarystats.reject_count:
+        sets = "set"
+        if summarystats.reject_count > 1:
+            sets = "sets"
+        print "Rejected %d package %s." % (summarystats.reject_count, sets)
+        Logger.log(["rejected", summarystats.reject_count])
+
     byebye()
 
     if not Options["No-Action"]:
-        if log_urgency:
-            UrgencyLog().close()
+        urgencylog.close()
 
     Logger.close()