[yocto] [[AUH] 17/17] statistics: Add support for publish_work_url setting.

Aníbal Limón anibal.limon at linux.intel.com
Wed Nov 25 16:00:46 PST 2015


Publish setting helps to point the url where the AUH patches and
logs are saved, this url is included into AUH upgrade status email.

Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
 README                |  3 +++
 modules/statistics.py | 10 ++++++++--
 upgradehelper.py      | 12 ++++++------
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/README b/README
index d0cc4ae..0756fdc 100644
--- a/README
+++ b/README
@@ -50,6 +50,9 @@ status_recipients=john.doe at doe.com
 # specify the directory where work (patches) will be saved (optional)
 #workdir=
 
+# publish url to use in statistics summary (optional)
+#publish_work_url=http://auh.somehost.com/work
+
 # clean sstate directory before upgrading
 clean_sstate=yes
 
diff --git a/modules/statistics.py b/modules/statistics.py
index 905a4cc..db83c5b 100644
--- a/modules/statistics.py
+++ b/modules/statistics.py
@@ -99,8 +99,14 @@ class Statistics(object):
 
         return stat_msg
 
-    def get_summary(self):
-        msg = self._pkg_stats()
+    def get_summary(self, publish_work_url, workdir):
+        msg = ''
+
+        if publish_work_url:
+            msg += "AUH finished upgrade batch the result patches/logs can be found at:\n" \
+                   "%s/%s, next are the statistics:\n\n" % (publish_work_url, workdir)
+
+        msg += self._pkg_stats()
         msg += self._maintainer_stats()
 
         return msg
diff --git a/upgradehelper.py b/upgradehelper.py
index d0e1439..0d3f8b2 100755
--- a/upgradehelper.py
+++ b/upgradehelper.py
@@ -393,7 +393,7 @@ class Updater(object):
             I(" %s: %s" % (pkg_ctx['PN'], e.stdout))
             raise e
 
-    def send_status_mail(self):
+    def send_status_mail(self, statistics_summary):
         if "status_recipients" not in settings:
             E(" Could not send status email, no recipients set!")
             return -1
@@ -402,10 +402,8 @@ class Updater(object):
 
         subject = "[AUH] Upgrade status: " + date.isoformat(date.today())
 
-        msg = self.statistics.get_summary()
-
         if self.statistics.total_attempted:
-            self.email_handler.send_email(to_list, subject, msg)
+            self.email_handler.send_email(to_list, subject, statistics_summary)
         else:
             W("No recipes attempted, not sending status mail!")
 
@@ -611,7 +609,9 @@ class Updater(object):
             self.pkg_upgrade_handler(pkg_ctx)
 
         if attempted_pkgs > 0:
-            statistics_summary = self.statistics.get_summary()
+            statistics_summary = self.statistics.get_summary(
+                    settings.get('publish_work_url', 'no'),
+                    os.path.basename(self.uh_work_dir))
 
             statistics_file = os.path.join(self.uh_work_dir,
                     "statistics_summary")
@@ -621,7 +621,7 @@ class Updater(object):
             I(" %s" % statistics_summary)
 
             if self.opts['send_email']:
-                self.send_status_mail()
+                self.send_status_mail(statistics_summary)
 
 class UniverseUpdater(Updater):
     def __init__(self):
-- 
2.1.4




More information about the yocto mailing list