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

[dak/master] optionally send emails on completed transitions



Signed-off-by: Mark Hymers <mhy@debian.org>
---
 config/debian/dak.conf       |    1 +
 dak/transitions.py           |   22 +++++++++++++++++++++-
 templates/transition.removed |   15 +++++++++++++++
 3 files changed, 37 insertions(+), 1 deletions(-)
 create mode 100644 templates/transition.removed

diff --git a/config/debian/dak.conf b/config/debian/dak.conf
index 4638b1c..756a37c 100644
--- a/config/debian/dak.conf
+++ b/config/debian/dak.conf
@@ -47,6 +47,7 @@ Dinstall
 
 Transitions
 {
+   Notifications "team@release.debian.org";
    TempPath "/srv/ftp.debian.org/tmp/";
 };
 
diff --git a/dak/transitions.py b/dak/transitions.py
index 3a1e2c8..4080f3e 100755
--- a/dak/transitions.py
+++ b/dak/transitions.py
@@ -394,8 +394,11 @@ def check_transitions(transitions):
     @note: Asks the user for confirmation first unless -a has been set.
 
     """
+    global Cnf
+
     to_dump = 0
     to_remove = []
+    info = {}
     # Now look through all defined transitions
     for trans in transitions:
         t = transitions[trans]
@@ -405,7 +408,8 @@ def check_transitions(transitions):
         # Will be None if nothing is in testing.
         current = database.get_suite_version(source, "testing")
 
-        print get_info(trans, source, expected, t["rm"], t["reason"], t["packages"])
+        info[trans] = get_info(trans, source, expected, t["rm"], t["reason"], t["packages"])
+        print info[trans]
 
         if current == None:
             # No package in testing
@@ -447,12 +451,28 @@ def check_transitions(transitions):
             sys.exit(0)
         elif answer == 'y':
             print "Committing"
+            subst = {}
+            subst['__TRANSITION_MESSAGE__'] = "The following transitions were removed:\n"
             for remove in to_remove:
+                subst['__TRANSITION_MESSAGE__'] += info[remove] + '\n'
                 del transitions[remove]
 
             edit_file = temp_transitions_file(transitions)
             write_transitions_from_file(edit_file)
 
+            # If we have a mail address configured for transitions,
+            # send a notification
+            subst['__TRANSITION_EMAIL__'] = Cnf.get("Transitions::Notifications", "")
+            if subst['__TRANSITION_EMAIL__'] != "":
+                print "Sending notification to %s" % subst['__TRANSITION__EMAIL__']
+                subst['__DAK_ADDRESS__'] = Cnf["Dinstall::MyEmailAddress"]
+                subst['__BCC__'] = 'X-DAK: dak transitions'
+                if Cnf.has_key("Dinstall::Bcc"):
+                    subst["__BCC__"] += '\nBcc: %s' % Cnf["Dinstall:Bcc"]
+                message = utils.TemplateSubst(subst,
+                                              os.path.join(Cnf["Dir::Templates"], 'transition.removed'))
+                utils.send_mail(message)
+
             print "Done"
         else:
             print "WTF are you typing?"
diff --git a/templates/transition.removed b/templates/transition.removed
new file mode 100644
index 0000000..32b0aca
--- /dev/null
+++ b/templates/transition.removed
@@ -0,0 +1,15 @@
+From: __DAK_ADDRESS__
+To: __TRANSITION_EMAIL__
+__BCC__
+X-Debian: DAK
+Precedence: bulk
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+Subject: Transitions Completed
+
+The following transitions are complete and have been removed
+from the transitions list:
+
+__TRANSITION_MESSAGE__
+
-- 
1.5.6.5


Reply to: