[Piuparts-commits] [piuparts] 06/10: piuparts-report.py: generate_global_summary()

Holger Levsen holger at moszumanska.debian.org
Mon Mar 3 02:57:25 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 9bb8332aef0c8d87324ccc801cbc07ccf311f646
Author: David Steele <dsteele at gmail.com>
Date:   Sat Feb 15 01:26:04 2014 -0500

    piuparts-report.py: generate_global_summary()
    
    At the end of processing, collect the section summary JSON files, and
    consolidate the information into a single global JSON. Add a special
    'overall' reporting-section, holding the 'worst' test result across
    all of the ohter reporting-sections.
---
 piuparts-report.py | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/piuparts-report.py b/piuparts-report.py
index 69019a2..6e4a4e7 100644
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@ -497,6 +497,7 @@ class Config(piupartslib.conf.Config):
                 "doc-root": "/",
                 "known-problem-directory": "@sharedir@/piuparts/known_problems",
                 "reporting-sections": "",
+                "precedence": 1,
                 "master-host": "piuparts.debian.org",
             },
             defaults_section=defaults_section)
@@ -1519,6 +1520,36 @@ class Section:
 
         self.generate_summary(master_host)
 
+def generate_global_summary(dir, sections):
+
+        json_name = "summary.json"
+
+        logging.debug("Generating global summary")
+
+        summ = pkgsummary.new_summ()
+
+        def by_precedence(secname):
+            return(by_precedence.section_precedence[secname])
+
+        by_precedence.section_precedence = {}
+        count = 0
+        for section in sections:
+            config = Config(section=section, defaults_section="global")
+            config.read(CONFIG_FILE)
+            by_precedence.section_precedence[section] = \
+                                            (config["precedence"], count)
+            count += 1
+
+        for section in sorted(sections, key=by_precedence):
+           sec_path = os.path.join(dir, section, json_name)
+           if os.path.isfile(sec_path):
+               sec_summ = pkgsummary.summ_read(sec_path)
+               summ = pkgsummary.merge_summ(summ, sec_summ)
+
+        summ_path = os.path.join(dir, json_name)
+        if os.path.isfile(summ_path):
+            os.unlink(summ_path)
+        pkgsummary.summ_write(summ, summ_path)
 
 # START detect_well_known_errors
 
@@ -1644,6 +1675,9 @@ def main():
                                    "doc_root": doc_root,
                     })
 
+        generate_global_summary(output_directory, section_names)
+
+        logging.debug("Done")
     else:
         logging.debug("Warning: %s does not exist!?! Creating it for you now." % master_directory)
         os.makedirs(master_directory)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list