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

[dak/master 08/11] centralise No-Mail handling



Signed-off-by: Mark Hymers <mhy@debian.org>
---
 dak/process_new.py      |    8 ++------
 daklib/queue.py         |   29 +++++++++++------------------
 daklib/queue_install.py |   26 ++++++++++++--------------
 daklib/utils.py         |    4 ++++
 4 files changed, 29 insertions(+), 38 deletions(-)

diff --git a/dak/process_new.py b/dak/process_new.py
index 17cf4e8..5a88ffc 100755
--- a/dak/process_new.py
+++ b/dak/process_new.py
@@ -493,9 +493,8 @@ def prod_maintainer (note, upload):
     prod_mail_message = utils.TemplateSubst(
         Subst,cnf["Dir::Templates"]+"/process-new.prod")
 
-    # Send the prod mail if appropriate
-    if not cnf["Dinstall::Options::No-Mail"]:
-        utils.send_mail(prod_mail_message)
+    # Send the prod mail
+    utils.send_mail(prod_mail_message)
 
     print "Sent proding message"
 
@@ -846,9 +845,6 @@ def main():
         sys.stderr.write("Sorting changes...\n")
     changes_files = sort_changes(changes_files, session)
 
-    # Kill me now? **FIXME**
-    cnf["Dinstall::Options::No-Mail"] = ""
-
     for changes_file in changes_files:
         changes_file = utils.validate_changes_file_arg(changes_file, 0)
         if not changes_file:
diff --git a/daklib/queue.py b/daklib/queue.py
index 9a238bb..a01a1e5 100755
--- a/daklib/queue.py
+++ b/daklib/queue.py
@@ -1927,16 +1927,13 @@ distribution."""
         if self.pkg.changes["architecture"].has_key("source") and cnf.get("Dir::UrgencyLog"):
             UrgencyLog().log(self.pkg.dsc["source"], self.pkg.dsc["version"], self.pkg.changes["urgency"])
 
-        # Send accept mail, announce to lists, close bugs and check for
-        # override disparities
-        if not cnf["Dinstall::Options::No-Mail"]:
-            self.update_subst()
-            self.Subst["__SUITE__"] = ""
-            self.Subst["__SUMMARY__"] = summary
-            mail_message = utils.TemplateSubst(self.Subst,
-                                               os.path.join(cnf["Dir::Templates"], 'process-unchecked.accepted'))
-            utils.send_mail(mail_message)
-            self.announce(short_summary, 1)
+        self.update_subst()
+        self.Subst["__SUITE__"] = ""
+        self.Subst["__SUMMARY__"] = summary
+        mail_message = utils.TemplateSubst(self.Subst,
+                                           os.path.join(cnf["Dir::Templates"], 'process-unchecked.accepted'))
+        utils.send_mail(mail_message)
+        self.announce(short_summary, 1)
 
         ## Helper stuff for DebBugs Version Tracking
         if cnf.Find("Dir::Queue::BTSVersionTrack"):
@@ -1998,11 +1995,8 @@ distribution."""
 
         cnf = Config()
 
-        # Abandon the check if:
-        #  a) override disparity checks have been disabled
-        #  b) we're not sending mail
-        if not cnf.FindB("Dinstall::OverrideDisparityCheck") or \
-           cnf["Dinstall::Options::No-Mail"]:
+        # Abandon the check if override disparity checks have been disabled
+        if not cnf.FindB("Dinstall::OverrideDisparityCheck"):
             return
 
         summary = self.pkg.check_override()
@@ -2192,9 +2186,8 @@ distribution."""
 
         os.close(reason_fd)
 
-        # Send the rejection mail if appropriate
-        if not cnf["Dinstall::Options::No-Mail"]:
-            utils.send_mail(reject_mail_message)
+        # Send the rejection mail
+        utils.send_mail(reject_mail_message)
 
         if self.logger:
             self.logger.log(["rejected", self.pkg.changes_file])
diff --git a/daklib/queue_install.py b/daklib/queue_install.py
index 3283e1e..912fdcb 100644
--- a/daklib/queue_install.py
+++ b/daklib/queue_install.py
@@ -69,13 +69,12 @@ def package_to_queue(u, summary, short_summary, queue, chg, session, announce=No
     u.check_override()
 
     # Send accept mail, announce to lists and close bugs
-    if announce and not cnf["Dinstall::Options::No-Mail"]:
-        template = os.path.join(cnf["Dir::Templates"], announce)
-        u.update_subst()
-        u.Subst["__SUITE__"] = ""
-        mail_message = utils.TemplateSubst(u.Subst, template)
-        utils.send_mail(mail_message)
-        u.announce(short_summary, True)
+    template = os.path.join(cnf["Dir::Templates"], announce)
+    u.update_subst()
+    u.Subst["__SUITE__"] = ""
+    mail_message = utils.TemplateSubst(u.Subst, template)
+    utils.send_mail(mail_message)
+    u.announce(short_summary, True)
 
 ################################################################################
 
@@ -233,13 +232,12 @@ def acknowledge_new(u, summary, short_summary, chg, session):
     session.add(chg)
     session.commit()
 
-    if not cnf["Dinstall::Options::No-Mail"]:
-        print "Sending new ack."
-        template = os.path.join(cnf["Dir::Templates"], 'process-unchecked.new')
-        u.update_subst()
-        u.Subst["__SUMMARY__"] = summary
-        new_ack_message = utils.TemplateSubst(u.Subst, template)
-        utils.send_mail(new_ack_message)
+    print "Sending new ack."
+    template = os.path.join(cnf["Dir::Templates"], 'process-unchecked.new')
+    u.update_subst()
+    u.Subst["__SUMMARY__"] = summary
+    new_ack_message = utils.TemplateSubst(u.Subst, template)
+    utils.send_mail(new_ack_message)
 
 ################################################################################
 
diff --git a/daklib/utils.py b/daklib/utils.py
index e745e1e..9c008b1 100644
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -572,6 +572,10 @@ def build_file_list(changes, is_a_dsc=0, field="files", hashname="md5sum"):
 def send_mail (message, filename=""):
     """sendmail wrapper, takes _either_ a message string or a file as arguments"""
 
+    # Check whether we're supposed to be sending mail
+    if Cnf.has_key("Dinstall::Options::No-Mail") and Cnf["Dinstall::Options::No-Mail"]:
+        return
+
     # If we've been passed a string dump it into a temporary file
     if message:
         (fd, filename) = tempfile.mkstemp()
-- 
1.6.3.3



Reply to: