]> git.decadent.org.uk Git - dak.git/blobdiff - dak/override.py
[rmurray] limit override to binaries for now
[dak.git] / dak / override.py
index 10e91e4551592e64e4aefbbc43e5f9534671971e..9b4b3f6d09344638a321b87cac5b42bdf3fd9515 100755 (executable)
 ################################################################################
 
 import pg, sys
-import apt_pkg, logging
-import dak.lib.database as database
-import dak.lib.utils as utils
+import apt_pkg
+import daklib.logging
+import daklib.database
+import daklib.utils
 
 ################################################################################
 
@@ -37,9 +38,9 @@ projectB = None
 
 ################################################################################
 
-# Shamelessly stolen from 'dak rm'. Should probably end up in utils.py
+# Shamelessly stolen from 'dak rm'. Should probably end up in daklib.utils.py
 def game_over():
-    answer = utils.our_raw_input("Continue (y/N)? ").lower()
+    answer = daklib.utils.our_raw_input("Continue (y/N)? ").lower()
     if answer != "y":
         print "Aborted."
         sys.exit(1)
@@ -47,7 +48,7 @@ def game_over():
 
 def usage (exit_code=0):
     print """Usage: dak override [OPTIONS] package [section] [priority]
-Make microchanges or microqueries of the overrides
+Make microchanges or microqueries of the binary overrides
 
   -h, --help                 show this help and exit
   -d, --done=BUG#            send priority/section change as closure to bug#
@@ -59,7 +60,7 @@ Make microchanges or microqueries of the overrides
 def main ():
     global Cnf, projectB
 
-    Cnf = utils.get_conf()
+    Cnf = daklib.utils.get_conf()
 
     Arguments = [('h',"help","Override::Options::Help"),
                  ('d',"done","Override::Options::Done", "HasArg"),
@@ -79,15 +80,15 @@ def main ():
        usage()
 
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
-    database.init(Cnf, projectB)
+    daklib.database.init(Cnf, projectB)
 
     if not arguments:
-        utils.fubar("package name is a required argument.")
+        daklib.utils.fubar("package name is a required argument.")
 
     package = arguments.pop(0)
     suite = Options["Suite"]
     if arguments and len(arguments) > 2:
-        utils.fubar("Too many arguments")
+        daklib.utils.fubar("Too many arguments")
 
     if arguments and len(arguments) == 1:
         # Determine if the argument is a priority or a section...
@@ -102,14 +103,16 @@ def main ():
         elif r[0][1] == 1:
             arguments = (".",arg)
         else:
-            utils.fubar("%s is not a valid section or priority" % (arg))
-
+            daklib.utils.fubar("%s is not a valid section or priority" % (arg))
 
     # Retrieve current section/priority...
+    # TODO: fetch dsc records and update them too, if needed.
     q = projectB.query("""
-    SELECT priority.priority AS prio, section.section AS sect
-      FROM override, priority, section, suite
+    SELECT priority.priority AS prio, section.section AS sect, override_type.type AS type
+      FROM override, priority, section, suite, override_type
      WHERE override.priority = priority.id
+       AND override.type = override_type.id
+       AND override_type.type != 'dsc'
        AND override.section = section.id
        AND override.package = %s
        AND override.suite = suite.id
@@ -117,9 +120,9 @@ def main ():
     """ % (pg._quote(package,"str"), pg._quote(suite,"str")))
 
     if q.ntuples() == 0:
-        utils.fubar("Unable to find package %s" % (package))
+        daklib.utils.fubar("Unable to find package %s" % (package))
     if q.ntuples() > 1:
-        utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples()))
+        daklib.utils.fubar("%s is ambiguous. Matches %d packages" % (package,q.ntuples()))
 
     r = q.getresult()
     oldsection = r[0][1]
@@ -142,14 +145,14 @@ def main ():
         pg._quote(newsection,"str")))
 
     if q.ntuples() == 0:
-        utils.fubar("Supplied section %s is invalid" % (newsection))
+        daklib.utils.fubar("Supplied section %s is invalid" % (newsection))
     newsecid = q.getresult()[0][0]
 
     q = projectB.query("SELECT id FROM priority WHERE priority=%s" % (
         pg._quote(newpriority,"str")))
 
     if q.ntuples() == 0:
-        utils.fubar("Supplied priority %s is invalid" % (newpriority))
+        daklib.utils.fubar("Supplied priority %s is invalid" % (newpriority))
     newprioid = q.getresult()[0][0]
 
     if newpriority == oldpriority and newsection == oldsection:
@@ -174,13 +177,13 @@ def main ():
 
     if not Options.has_key("Done"):
         pass
-        #utils.warn("No bugs to close have been specified. Noone will know you have done this.")
+        #daklib.utils.warn("No bugs to close have been specified. Noone will know you have done this.")
     else:
         print "I: Will close bug(s): %s" % (Options["Done"])
 
     game_over()
 
-    Logger = logging.Logger(Cnf, "override")
+    Logger = daklib.logging.Logger(Cnf, "override")
 
     projectB.query("BEGIN WORK")
     # We're in "do it" mode, we have something to do... do it
@@ -220,10 +223,10 @@ def main ():
             Subst["__BCC__"] = "Bcc: " + ", ".join(bcc)
         else:
             Subst["__BCC__"] = "X-Filler: 42"
-        Subst["__CC__"] = "X-DAK: dak override"
+        Subst["__CC__"] = "X-DAK: dak override\nX-Katie: alicia $Revision: 1.6$"
         Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"]
         Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"]
-        Subst["__WHOAMI__"] = utils.whoami()
+        Subst["__WHOAMI__"] = daklib.utils.whoami()
 
         summary = "Concerning package %s...\n" % (package)
         summary += "Operating on the %s suite\n" % (suite)
@@ -233,11 +236,11 @@ def main ():
             summary += "Changed section from %s to %s\n" % (oldsection,newsection)
         Subst["__SUMMARY__"] = summary
 
-        for bug in utils.split_args(Options["Done"]):
+        for bug in daklib.utils.split_args(Options["Done"]):
             Subst["__BUG_NUMBER__"] = bug
-            mail_message = utils.TemplateSubst(
+            mail_message = daklib.utils.TemplateSubst(
                 Subst,Cnf["Dir::Templates"]+"/override.bug-close")
-            utils.send_mail(mail_message)
+            daklib.utils.send_mail(mail_message)
             Logger.log(["closed bug",bug])
 
     Logger.close()