notifications: make notify() more generic
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 13 May 2014 13:41:32 +0000 (16:41 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 5 Jun 2014 11:03:13 +0000 (14:03 +0300)
In order to be able to re-use it in other tools than git-buildpackage.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/notifications.py
gbp/scripts/buildpackage.py

index 95c4bf4..d60450e 100644 (file)
@@ -53,7 +53,7 @@ def send_notification(summary, msg):
     return True
 
 
-def notify(cp, success, notify_opt):
+def notify(summary, message, notify_opt):
     """
     Send a notifications
     @return: False on error
@@ -66,6 +66,5 @@ def notify(cp, success, notify_opt):
     if not enable:
         return [True, False][notify_opt.is_on()]
 
-    summary, msg = build_msg(cp, success)
-    return notify_opt.do(send_notification, summary, msg)
+    return notify_opt.do(send_notification, summary, message)
 
index 54e66bd..2142475 100755 (executable)
@@ -628,11 +628,12 @@ def main(argv):
         if options.export_dir and options.purge and not retval:
             RemoveTree(export_dir)()
 
-        if source and not gbp.notifications.notify(source.changelog,
-                                                   not retval,
-                                                   options.notify):
-            gbp.log.err("Failed to send notification")
-            retval = 1
+        if source:
+            summary, msg = gbp.notifications.build_msg(source.changelog,
+                                                       not retval)
+            if not gbp.notifications.notify(summary, msg, options.notify):
+                gbp.log.err("Failed to send notification")
+                retval = 1
 
     return retval