[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. 0.51
David Steele
dsteele at gmail.com
Wed May 15 10:09:34 UTC 2013
The following commit has been merged in the master branch:
commit 99ab8d859148a003ad94e69fc37fd717c99f29e8
Author: David Steele <dsteele at gmail.com>
Date: Wed Jan 9 21:40:29 2013 -0500
detect_well_known_errors.py - Create Failure Mgr class to hold kpr fails.
diff --git a/master-bin/detect_well_known_errors.py b/master-bin/detect_well_known_errors.py
index dcb2d96..5706247 100755
--- a/master-bin/detect_well_known_errors.py
+++ b/master-bin/detect_well_known_errors.py
@@ -6,6 +6,7 @@ import os
import time
import re
import subprocess
+from collections import namedtuple
CONFIG_FILE = "/etc/piuparts/piuparts.conf"
KPR_DIRS = ( 'pass', 'bugged', 'affected', 'fail' )
@@ -78,6 +79,50 @@ class Problem():
return( False )
+class FailureManager():
+ """Class to track known failures encountered, by package,
+ where (e.g. 'fail'), and known problem type"""
+
+ def __init__(self, logdict):
+ """logdict is {pkgspec: fulllogpath} across all log files"""
+
+ self.logdict = logdict
+ self.failures = []
+
+ self.load_failures()
+
+ def load_failures(self):
+ """Collect failures across all kpr files, as named tuples"""
+
+ for pkgspec in self.logdict:
+ logpath = self.logdict[pkgspec]
+ try:
+ kp = open( get_kpr_path(logpath), 'r' )
+
+ for line in kp.readlines():
+ (where, problem) = self.parse_kpr_line( line )
+
+ self.failures.append( make_failure(where, problem, pkgspec) )
+
+ kp.close()
+ except IOError:
+ print "Error processing %s" % get_kpr_path(logpath)
+
+ def parse_kpr_line( self, line ):
+ """Parse a line in a kpr file into where (e.g. 'pass') and problem name"""
+
+ m = re.search( "^([a-z]+)/.+ (.+)$", line )
+ return( m.group(1), m.group(2) )
+
+ def sort_by_path( self ):
+ self.failures.sort(key=lambda x: self.logdict[x.pkgspec])
+
+ def filtered( self, problem ):
+ return([x for x in self.failures if problem==x.problem])
+
+def make_failure( where, problem, pkgspec ):
+ return(namedtuple('Failure', 'where problem pkgspec')(where, problem, pkgspec))
+
def get_where( logpath ):
"""Convert a path to a log file to the 'where' component (e.g. 'pass')"""
return( logpath.split('/')[-2] )
@@ -176,6 +221,9 @@ def process_section( section, config, problem_list ):
add_cnt = make_kprs( logdict, kprdict, problem_list )
+ failures = FailureManager( logdict )
+ failures.sort_by_path()
+
def detect_well_known_errors( config, problem_list ):
for section in config['sections'].split(" "):
--
piuparts git repository
More information about the Piuparts-commits
mailing list