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

[dak/master 09/50] process-upload: import action() from process-unchecked



Signed-off-by: Frank Lichtenheld <djpig@debian.org>
---
 dak/process_upload.py   |   72 ++++++++++++++++++++++++++++++++++++++++++++++-
 daklib/queue_install.py |   26 +++++++++--------
 2 files changed, 85 insertions(+), 13 deletions(-)

diff --git a/dak/process_upload.py b/dak/process_upload.py
index 3e923ea..e3a19ac 100755
--- a/dak/process_upload.py
+++ b/dak/process_upload.py
@@ -135,6 +135,7 @@ import apt_pkg
 
 from daklib import daklog
 from daklib.queue import *
+from daklib.queue_install import *
 from daklib import utils
 from daklib.dbconn import *
 #from daklib.dak_exceptions import *
@@ -163,6 +164,75 @@ def usage (exit_code=0):
 
 ###############################################################################
 
+def action(u):
+    cnf = Config()
+
+    # changes["distribution"] may not exist in corner cases
+    # (e.g. unreadable changes files)
+    if not u.pkg.changes.has_key("distribution") or not isinstance(u.pkg.changes["distribution"], DictType):
+        u.pkg.changes["distribution"] = {}
+
+    (summary, short_summary) = u.build_summaries()
+
+    (prompt, answer) = ("", "XXX")
+    if Options["No-Action"] or Options["Automatic"]:
+        answer = 'S'
+
+    queuekey = ''
+
+    pi = u.package_info()
+
+    if len(u.rejects) > 0:
+        if u.upload_too_new():
+            print "SKIP (too new)\n" + pi,
+            prompt = "[S]kip, Quit ?"
+        else:
+            print "REJECT\n" + pi
+            prompt = "[R]eject, Skip, Quit ?"
+            if Options["Automatic"]:
+                answer = 'R'
+    else:
+        qu = determine_target(u)
+        if qu:
+            print "%s for %s\n%s%s" % ( qu.upper(), ", ".join(u.pkg.changes["distribution"].keys()), pi, summary)
+            queuekey = qu[0].upper()
+            if queuekey in "RQSA":
+                queuekey = "D"
+                prompt = "[D]ivert, Skip, Quit ?"
+            else:
+                prompt = "[%s]%s, Skip, Quit ?" % (queuekey, qu[1:].lower())
+            if Options["Automatic"]:
+                answer = queuekey
+        else:
+            print "ACCEPT\n" + pi + summary,
+            prompt = "[A]ccept, Skip, Quit ?"
+            if Options["Automatic"]:
+                answer = 'A'
+
+    while prompt.find(answer) == -1:
+        answer = utils.our_raw_input(prompt)
+        m = re_default_answer.match(prompt)
+        if answer == "":
+            answer = m.group(1)
+        answer = answer[:1].upper()
+
+    if answer == 'R':
+        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 )
+        QueueInfo[qu]["process"](u, summary, short_summary)
+        u.remove()
+    elif answer == 'Q':
+        sys.exit(0)
+
+###############################################################################
+
 def process_it(changes_file):
     global Logger
 
@@ -229,7 +299,7 @@ def process_it(changes_file):
             u.check_timestamps()
             u.check_signed_by_key()
 
-#        action(u)
+        action(u)
 
     except (SystemExit, KeyboardInterrupt):
         raise
diff --git a/daklib/queue_install.py b/daklib/queue_install.py
index c517f53..ef35ef5 100644
--- a/daklib/queue_install.py
+++ b/daklib/queue_install.py
@@ -33,18 +33,6 @@ from daklib.config import Config
 
 ###############################################################################
 
-# q-unapproved hax0ring
-QueueInfo = {
-    "New": { "is": is_new, "process": acknowledge_new },
-    "Autobyhand" : { "is" : is_autobyhand, "process": do_autobyhand },
-    "Byhand" : { "is": is_byhand, "process": do_byhand },
-    "OldStableUpdate" : { "is": is_oldstableupdate,
-                          "process": do_oldstableupdate },
-    "StableUpdate" : { "is": is_stableupdate, "process": do_stableupdate },
-    "Unembargo" : { "is": is_unembargo, "process": queue_unembargo },
-    "Embargo" : { "is": is_embargo, "process": queue_embargo },
-}
-
 def determine_target(u):
     cnf = Config()
     
@@ -284,3 +272,17 @@ def acknowledge_new(u, summary, short_summary):
         u.Subst["__SUMMARY__"] = summary
         new_ack_message = utils.TemplateSubst(u.Subst, template)
         utils.send_mail(new_ack_message)
+
+################################################################################
+
+# q-unapproved hax0ring
+QueueInfo = {
+    "New": { "is": is_new, "process": acknowledge_new },
+    "Autobyhand" : { "is" : is_autobyhand, "process": do_autobyhand },
+    "Byhand" : { "is": is_byhand, "process": do_byhand },
+    "OldStableUpdate" : { "is": is_oldstableupdate,
+                          "process": do_oldstableupdate },
+    "StableUpdate" : { "is": is_stableupdate, "process": do_stableupdate },
+    "Unembargo" : { "is": is_unembargo, "process": queue_unembargo },
+    "Embargo" : { "is": is_embargo, "process": queue_embargo },
+}
-- 
1.6.3.3



Reply to: