All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: yocto@yoctoproject.org
Cc: paul.eggleton@linux.intel.com
Subject: [[AUH] 16/17] statistics: Improve email format and get_summary method.
Date: Wed, 25 Nov 2015 18:00:45 -0600	[thread overview]
Message-ID: <1448496046-13186-17-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1448496046-13186-1-git-send-email-anibal.limon@linux.intel.com>

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 modules/statistics.py | 24 ++++++++++++++----------
 upgradehelper.py      | 11 +++++------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/modules/statistics.py b/modules/statistics.py
index 32a6748..905a4cc 100644
--- a/modules/statistics.py
+++ b/modules/statistics.py
@@ -62,16 +62,15 @@ class Statistics(object):
 
         self.total_attempted += 1
 
-    def pkg_stats(self):
-        stat_msg = "\nUpgrade statistics:\n"
-        stat_msg += "====================================================\n"
+    def _pkg_stats(self):
+        stat_msg = "Recipe upgrade statistics:\n\n"
         for status in self.upgrade_stats:
             list_len = len(self.upgrade_stats[status])
             if list_len > 0:
-                stat_msg += "* " + status + ": " + str(list_len) + "\n"
+                stat_msg += "    * " + status + ": " + str(list_len) + "\n"
 
                 for pkg, new_ver, maintainer in self.upgrade_stats[status]:
-                    stat_msg += "    " + pkg + ", " + new_ver + ", " + \
+                    stat_msg += "        " + pkg + ", " + new_ver + ", " + \
                                 maintainer + "\n"
 
         if self.total_attempted == 0:
@@ -80,8 +79,7 @@ class Statistics(object):
         else:
             percent_succeded = self.succeeded["total"] * 100.0 / self.total_attempted
             percent_failed = self.failed["total"] * 100.0 / self.total_attempted
-        stat_msg += "++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
-        stat_msg += "TOTAL: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n\n" % \
+        stat_msg += "\n    TOTAL: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n\n" % \
                     (self.total_attempted, self.succeeded["total"],
                     percent_succeded,
                     self.failed["total"],
@@ -89,14 +87,20 @@ class Statistics(object):
 
         return stat_msg
 
-    def maintainer_stats(self):
-        stat_msg = "* Statistics per maintainer:\n"
+    def _maintainer_stats(self):
+        stat_msg = "Recipe upgrade statistics per Maintainer:\n\n"
         for m in self.maintainers:
             attempted = self.succeeded[m] + self.failed[m]
-            stat_msg += "    %s: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n\n" % \
+            stat_msg += "    %s: attempted=%d succeeded=%d(%.2f%%) failed=%d(%.2f%%)\n" % \
                         (m.split("@")[0], attempted, self.succeeded[m],
                         self.succeeded[m] * 100.0 / attempted,
                         self.failed[m],
                         self.failed[m] * 100.0 / attempted)
 
         return stat_msg
+
+    def get_summary(self):
+        msg = self._pkg_stats()
+        msg += self._maintainer_stats()
+
+        return msg
diff --git a/upgradehelper.py b/upgradehelper.py
index f9d915a..d0e1439 100755
--- a/upgradehelper.py
+++ b/upgradehelper.py
@@ -395,14 +395,14 @@ class Updater(object):
 
     def send_status_mail(self):
         if "status_recipients" not in settings:
-            E("Could not send status email, no recipients set!")
+            E(" Could not send status email, no recipients set!")
             return -1
 
         to_list = settings["status_recipients"].split()
 
         subject = "[AUH] Upgrade status: " + date.isoformat(date.today())
 
-        msg = self.statistics.pkg_stats() + self.statistics.maintainer_stats()
+        msg = self.statistics.get_summary()
 
         if self.statistics.total_attempted:
             self.email_handler.send_email(to_list, subject, msg)
@@ -610,16 +610,15 @@ class Updater(object):
             pkg_ctx = pkgs_ctx[pn]
             self.pkg_upgrade_handler(pkg_ctx)
 
-        if attempted_pkgs > 1:
-            statistics_summary = self.statistics.pkg_stats() + \
-                    self.statistics.maintainer_stats()
+        if attempted_pkgs > 0:
+            statistics_summary = self.statistics.get_summary()
 
             statistics_file = os.path.join(self.uh_work_dir,
                     "statistics_summary")
             with open(statistics_file, "w+") as f:
                 f.write(statistics_summary)
 
-            I("%s" % statistics_summary)
+            I(" %s" % statistics_summary)
 
             if self.opts['send_email']:
                 self.send_status_mail()
-- 
2.1.4



  parent reply	other threads:[~2015-11-26  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-26  0:00 [[AUH] 00/17] AUH code refactor and support test image Aníbal Limón
2015-11-26  0:00 ` [[AUH] 01/17] {upgradehelper, bitbake}.py: Move _get_env function to bitbake Aníbal Limón
2015-11-26  0:00 ` [[AUH] 02/17] upgradehelper.py: Merge options into a dictionary Aníbal Limón
2015-11-26  0:00 ` [[AUH] 03/17] upgradehelper.py: Adds own module for steps Aníbal Limón
2015-11-26  0:00 ` [[AUH] 04/17] upgradehelper: Reorder files into directories Aníbal Limón
2015-11-26  0:00 ` [[AUH] 05/17] buildhistory: Add option for enable in upgrade-helper.conf Aníbal Limón
2015-11-26  0:00 ` [[AUH] 06/17] recipe/base.py: Add is_recipe_or_include_file func Aníbal Limón
2015-11-26  0:00 ` [[AUH] 07/17] recipe/base.py: Add modify_recipe_files function decorator Aníbal Limón
2015-11-26  0:00 ` [[AUH] 08/17] recipe/base.py: Add support for get recipe inherits Aníbal Limón
2015-11-26 20:25   ` Paul Eggleton
2015-11-27 16:50     ` Aníbal Limón
2015-11-26  0:00 ` [[AUH] 09/17] steps.py: Merge load_dirs step into load_env Aníbal Limón
2015-11-26  0:00 ` [[AUH] 10/17] steps.py: Move clean_repo to first step Aníbal Limón
2015-11-26  0:00 ` [[AUH] 11/17] utils/git.py: Add method for apply patches into a branch Aníbal Limón
2015-11-26 20:28   ` Paul Eggleton
2015-11-27 16:51     ` Aníbal Limón
2015-11-26  0:00 ` [[AUH] 12/17] upgradehelper.py: Add settings for enable testimage Aníbal Limón
2015-11-26  0:00 ` [[AUH] 13/17] upgradehelper: Add testimage feature Aníbal Limón
2015-11-26 20:29   ` Paul Eggleton
2015-11-27 16:51     ` Aníbal Limón
2015-11-26  0:00 ` [[AUH] 14/17] upgradehelper.py: Changed retry failure build to 30 days Aníbal Limón
2015-11-26  0:00 ` [[AUH] 15/17] upgradehelper: Add workdir setting Aníbal Limón
2015-11-26  0:00 ` Aníbal Limón [this message]
2015-11-26  0:00 ` [[AUH] 17/17] statistics: Add support for publish_work_url setting Aníbal Limón

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448496046-13186-17-git-send-email-anibal.limon@linux.intel.com \
    --to=anibal.limon@linux.intel.com \
    --cc=paul.eggleton@linux.intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.