[Piuparts-devel] dwke crash on piatti, take 2

Dave Steele dsteele at gmail.com
Thu May 9 06:18:07 UTC 2013


branch branch rrdep_err:


c231268 dwke - Fix error handline for package metric retrieval.


>From c2312689a5f915b7a66ce1b939c2a02e614f8bbe Mon Sep 17 00:00:00 2001
From: David Steele <dsteele at gmail.com>
Date: Thu, 9 May 2013 02:10:29 -0400
Subject: [PATCH] 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.
---
 master-bin/detect_well_known_errors |   29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

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"
--
1.7.10.4



More information about the Piuparts-devel mailing list