[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. 0.51

David Steele dsteele at gmail.com
Wed May 15 10:09:36 UTC 2013


The following commit has been merged in the master branch:
commit 35f119645a909ab852b955eda1c0fa7efa13bc95
Author: David Steele <dsteele at gmail.com>
Date:   Thu Jan 10 22:30:51 2013 -0500

    detect_well_known_errors - Sort known errors/issues by rdep count.

diff --git a/debian/changelog b/debian/changelog
index ac42d66..f6be0ec 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -30,6 +30,8 @@ piuparts (0.51) UNRELEASED; urgency=low
   [ David Steele ]
   * detect_well_known_errors:
     - Replace the bash script with an equivalent Python script.
+    - Sort known error and issue packages by reverse dependency count.
+      (Closes: #698526)
     - Minor HTML syntax fix.
     - Minor template integration.
 
diff --git a/master-bin/detect_well_known_errors b/master-bin/detect_well_known_errors
index 913c73f..832e67c 100755
--- a/master-bin/detect_well_known_errors
+++ b/master-bin/detect_well_known_errors
@@ -26,6 +26,7 @@ import subprocess
 from collections import namedtuple
 
 CONFIG_FILE = "/etc/piuparts/piuparts.conf"
+DISTRO_CONFIG_FILE = "/etc/piuparts/distros.conf"
 KPR_DIRS = ( 'pass', 'bugged', 'affected', 'fail' )
 
 KPR_EXT = '.kpr'
@@ -79,6 +80,19 @@ class WKE_Config( piupartslib.conf.Config ):
                 "output-directory": "/var/lib/piuparts/htdocs/",
             }, "" )
 
+class WKE_Section_Config( piupartslib.conf.Config ):
+
+    def __init__( self, section ):
+        self.section = section
+
+        piupartslib.conf.Config.__init__( self, self.section,
+            {
+                "distro": None,
+                "mirror": None,
+                "area": None,
+                "arch": None,
+            }, "",  defaults_section="global" )
+
 class Problem():
     """ Encapsulate a particular known problem """
 
@@ -167,6 +181,19 @@ class FailureManager():
     def sort_by_path( self ):
         self.failures.sort(key=lambda x: self.logdict[x.pkgspec])
 
+    def sort_by_rdeps( self, pkgsdb ):
+        self.pkgsdb = pkgsdb
+
+        def keyfunc( x, pkgsdb=self.pkgsdb, logdict=self.logdict):
+            try:
+                rdeps = pkgsdb.get_package(get_pkg(x.pkgspec)).rrdep_count()
+            except KeyError:
+                rdeps = 0
+
+            return( (-rdeps, logdict[x.pkgspec]) )
+
+        self.failures.sort( key=keyfunc )
+
     def filtered( self, problem ):
         return([x for x in self.failures if problem==x.problem])
 
@@ -322,13 +349,22 @@ def update_html( section, logdict, problem_list, failures, config ):
     knownfailpkgs = set([failure.pkgspec for failure in failures.failures])
     unknownsasfailures = [make_failure("","unknown_failures.conf",x)
                          for x in failedpkgs.difference(knownfailpkgs)]
-    unknownsasfailures = sorted( unknownsasfailures, lambda x: logdict[x] )
+
+    def keyfunc( x, pkgsdb=pkgsdb, logdict=logdict):
+        try:
+            rdeps = pkgsdb.get_package(get_pkg(x.pkgspec)).rrdep_count()
+        except KeyError:
+            rdeps = 0
+
+        return( (-rdeps, logdict[x.pkgspec]) )
+
+    unknownsasfailures.sort( key=keyfunc )
 
     update_tpl( html_dir, section, problem_list[0], unknownsasfailures,
                 logdict,
                 PKG_ERROR_TPL, UNKNOWN_TPL, )
 
-def process_section( section, config, problem_list ):
+def process_section( section, config, problem_list, pkgsdb=None ):
     """ Update .bug and .kpr files for logs in this section """
 
     sectiondir = os.path.join( config['master-directory'], section )
@@ -349,8 +385,32 @@ def process_section( section, config, problem_list ):
 
     add_cnt = make_kprs( logdict, kprdict, problem_list )
 
+    if not pkgsdb:
+        oldcwd = os.getcwd()
+        os.chdir(config['master-directory'])
+
+        section_config = WKE_Section_Config( section )
+        section_config.read( CONFIG_FILE )
+
+        distro_config = piupartslib.conf.DistroConfig(
+                        DISTRO_CONFIG_FILE, section_config["mirror"])
+
+        pkgsdb = piupartslib.packagesdb.PackagesDB(prefix=section)
+
+        pkgs_url = distro_config.get_packages_url(
+                   section_config.get_distro(),
+                   section_config.get_area(),
+                   section_config.get_arch() )
+        pkg_fl = piupartslib.open_packages_url(pkgs_url)
+        pkgsdb.read_packages_file(pkg_fl)
+        pkg_fl.close()
+
+        pkgsdb.calc_rrdep_counts()
+
+        os.chdir(oldcwd)
+
     failures = FailureManager( logdict )
-    failures.sort_by_path()
+    failures.sort_by_rdeps(pkgsdb)
 
     update_html( section, logdict, problem_list, failures, config )
 

-- 
piuparts git repository



More information about the Piuparts-commits mailing list