]> git.decadent.org.uk Git - dak.git/blobdiff - dak/process_new.py
Merge remote-tracking branch 'drkranz/fixes' into merge
[dak.git] / dak / process_new.py
index e0ed4b81370765c6566cd1fdf5dc6e414b8e42f5..53b4bf7be608cb341dd128b78254123024c96611 100755 (executable)
@@ -64,6 +64,7 @@ from daklib.dak_exceptions import CantOpenError, AlreadyLockedError, CantGetLock
 from daklib.summarystats import SummaryStats
 from daklib.config import Config
 from daklib.policy import UploadCopy, PolicyQueueUploadHandler
 from daklib.summarystats import SummaryStats
 from daklib.config import Config
 from daklib.policy import UploadCopy, PolicyQueueUploadHandler
+from sqlalchemy.sql import not_
 
 # Globals
 Options = None
 
 # Globals
 Options = None
@@ -118,6 +119,26 @@ class Priority_Completer:
 
 ################################################################################
 
 
 ################################################################################
 
+def claimed_overrides(upload, missing, session):
+    source = [upload.source.source]
+    binaries = set([x.package for x in upload.binaries])
+    suites = ('unstable','experimental')
+    for m in missing:
+        if m['type'] != 'dsc':
+            binaries.remove(m['package'])
+    if binaries:
+        return session.query(DBBinary.package, DBSource.source).distinct(). \
+                             filter(DBBinary.package.in_(binaries)). \
+                             join(DBBinary.source). \
+                             filter(not_(DBSource.source.in_(source))). \
+                             join(DBBinary.suites). \
+                             filter(Suite.suite_name.in_(suites)). \
+                             order_by(DBSource.source, DBBinary.package)
+    else:
+        return None
+
+################################################################################
+
 def print_new (upload, missing, indexed, session, file=sys.stdout):
     check_valid(missing, session)
     index = 0
 def print_new (upload, missing, indexed, session, file=sys.stdout):
     check_valid(missing, session)
     index = 0
@@ -137,6 +158,11 @@ def print_new (upload, missing, indexed, session, file=sys.stdout):
         if not m['valid']:
             line = line + ' [!]'
         print >>file, line
         if not m['valid']:
             line = line + ' [!]'
         print >>file, line
+    claimed = claimed_overrides(upload, missing, session)
+    if claimed and claimed.count():
+        print '\nCLAIMED OVERRIDES'
+        for c in claimed:
+            print '%s: %s' % (c.source, c.package)
     notes = get_new_comments(upload.policy_queue, upload.changes.source)
     for note in notes:
         print "\nAuthor: %s\nVersion: %s\nTimestamp: %s\n\n%s" \
     notes = get_new_comments(upload.policy_queue, upload.changes.source)
     for note in notes:
         print "\nAuthor: %s\nVersion: %s\nTimestamp: %s\n\n%s" \
@@ -527,17 +553,12 @@ def do_new(upload, upload_copy, handler, session):
             continue
 
         if answer == 'A' and not Options["Trainee"]:
             continue
 
         if answer == 'A' and not Options["Trainee"]:
-            try:
-                check_daily_lock()
-                add_overrides(missing, upload.target_suite, session)
-                if Config().find_b("Dinstall::BXANotify"):
-                    do_bxa_notification(missing, upload, session)
-                handler.accept()
-                done = True
-                Logger.log(["NEW ACCEPT", upload.changes.changesname])
-            except CantGetLockError:
-                print "Hello? Operator! Give me the number for 911!"
-                print "Dinstall in the locked area, cant process packages, come back later"
+            add_overrides(missing, upload.target_suite, session)
+            if Config().find_b("Dinstall::BXANotify"):
+                do_bxa_notification(missing, upload, session)
+            handler.accept()
+            done = True
+            Logger.log(["NEW ACCEPT", upload.changes.changesname])
         elif answer == 'C':
             check_pkg(upload, upload_copy, session)
         elif answer == 'E' and not Options["Trainee"]:
         elif answer == 'C':
             check_pkg(upload, upload_copy, session)
         elif answer == 'E' and not Options["Trainee"]:
@@ -595,6 +616,7 @@ def usage (exit_code=0):
   -h, --help                show this help and exit.
   -m, --manual-reject=MSG   manual reject with `msg'
   -n, --no-action           don't do anything
   -h, --help                show this help and exit.
   -m, --manual-reject=MSG   manual reject with `msg'
   -n, --no-action           don't do anything
+  -q, --queue=QUEUE         operate on a different queue
   -t, --trainee             FTP Trainee mode
   -V, --version             display the version number and exit
 
   -t, --trainee             FTP Trainee mode
   -V, --version             display the version number and exit
 
@@ -624,24 +646,6 @@ ENVIRONMENT VARIABLES
 
 ################################################################################
 
 
 ################################################################################
 
-def check_daily_lock():
-    """
-    Raises CantGetLockError if the dinstall daily.lock exists.
-    """
-
-    cnf = Config()
-    try:
-        lockfile = cnf.get("Process-New::DinstallLockFile",
-                           os.path.join(cnf['Dir::Lock'], 'processnew.lock'))
-
-        os.open(lockfile,
-                os.O_RDONLY | os.O_CREAT | os.O_EXCL)
-    except OSError as e:
-        if e.errno == errno.EEXIST or e.errno == errno.EACCES:
-            raise CantGetLockError
-
-    os.unlink(lockfile)
-
 @contextlib.contextmanager
 def lock_package(package):
     """
 @contextlib.contextmanager
 def lock_package(package):
     """