[Piuparts-commits] [SCM] piuparts git repository branch, piatti, updated. 0.50-124-gd69072e

David Steele dsteele at gmail.com
Thu May 9 10:29:16 UTC 2013


The following commit has been merged in the piatti branch:
commit c2312689a5f915b7a66ce1b939c2a02e614f8bbe
Author: David Steele <dsteele at gmail.com>
Date:   Thu May 9 02:10:29 2013 -0400

    dwke - Fix error handline for package metric retrieval.
    
    It no longer throws a KeyError when the package is missing from
    the distribution. Check explicitly for None.

diff --git a/master-bin/detect_well_known_errors b/master-bin/detect_well_known_errors
index 80f224e..1a3ce24 100755
--- a/master-bin/detect_well_known_errors
+++ b/master-bin/detect_well_known_errors
@@ -228,10 +228,12 @@ class FailureManager():
         self.pkgsdb = pkgsdb
 
         def keyfunc( x, pkgsdb=self.pkgsdb, logdict=self.logdict):
-            try:
-                pkg_name = get_pkg(x.pkgspec)
-                rdeps = pkgsdb.get_package(pkg_name).rrdep_count()
-            except KeyError:
+
+            pkg_obj = pkgsdb.get_package(get_pkg(x.pkgspec))
+
+            if not pkg_obj is None:
+                rdeps = pkg_obj.rrdep_count()
+            else:
                 rdeps = 0
 
             is_failed = get_where(logdict[x.pkgspec]) == "fail"
@@ -377,10 +379,13 @@ def update_tpl( basedir, section, problem, failures, logdict, ftpl, ptpl, pkgsdb
 
         pkgspec = failure.pkgspec
         bin_pkg = get_pkg(pkgspec)
-        try:
+
+        pkg_obj = pkgsdb.get_package(bin_pkg)
+
+        if not pkg_obj is None:
             src_pkg = source_pkg(pkgspec, pkgsdb)
-            rdep_cnt = pkgsdb.get_package(bin_pkg).rrdep_count()
-        except KeyError:
+            rdep_cnt = pkg_obj.rrdep_count()
+        else:
             src_pkg = bin_pkg
             rdep_cnt = 0
 
@@ -431,10 +436,12 @@ def update_html( section, logdict, problem_list, failures, config, pkgsdb ):
                          for x in failedpkgs.difference(knownfailpkgs)]
 
     def keyfunc( x, pkgsdb=pkgsdb, logdict=logdict):
-        try:
-            pkg_name = get_pkg(x.pkgspec)
-            rdeps = pkgsdb.get_package(pkg_name).rrdep_count()
-        except KeyError:
+
+        pkg_obj =  pkgsdb.get_package(get_pkg(x.pkgspec))
+
+        if not pkg_obj is None:
+            rdeps = pkg_obj.rrdep_count()
+        else:
             rdeps = 0
 
         is_failed = get_where(logdict[x.pkgspec]) == "fail"

-- 
piuparts git repository



More information about the Piuparts-commits mailing list