[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.50-46-gfb2efac

David Steele dsteele at gmail.com
Mon Mar 25 12:25:58 UTC 2013


The following commit has been merged in the develop branch:
commit 385ac72ddb6566abd0f5814cd42cfbcd9fbd0d5b
Author: David Steele <dsteele at gmail.com>
Date:   Wed Jan 9 21:33:00 2013 -0500

    detect_well_known_errors.py - Create missing kpr files.

diff --git a/master-bin/detect_well_known_errors.py b/master-bin/detect_well_known_errors.py
index 2d50655..dcb2d96 100755
--- a/master-bin/detect_well_known_errors.py
+++ b/master-bin/detect_well_known_errors.py
@@ -82,6 +82,14 @@ def get_where( logpath ):
     """Convert a path to a log file to the 'where' component (e.g. 'pass')"""
     return( logpath.split('/')[-2] )
 
+def replace_ext( fpath, newext ):
+    basename = os.path.splitext( os.path.split(fpath)[1] )[0]
+    return('/'.join( fpath.split('/')[:-1] + [basename + newext] ))
+
+def get_kpr_path( logpath ):
+    """Return the kpr file path for a particular log path"""
+    return( replace_ext( logpath, KPR_EXT ) )
+
 def get_file_dict( workdirs, ext ):
     """For files in [workdirs] with extension 'ext', create a dict of
        <pkgname>_<version>: <path>"""
@@ -118,6 +126,35 @@ def clean_cache_files( logdict, cachedict, skipnewer=False ):
 
     return( count )
 
+def make_kprs( logdict, kprdict, problem_list ):
+    """Create kpr files, as necessary, so every log file has one
+       kpr entries are e.g.
+           fail/xorg-docs_1:1.6-1.log broken_symlinks_error.conf"""
+
+    needs_kpr = set(logdict.keys()).difference(set(kprdict.keys()))
+
+    for pkg_spec in needs_kpr:
+        logpath = logdict[pkg_spec]
+
+        try:
+            lb = open( logpath, 'r' )
+            logbody = lb.read()
+            lb.close()
+
+            where = get_where( logpath )
+
+            kf = open( get_kpr_path(logpath), 'a')
+
+            for problem in problem_list:
+                if( problem.has_problem( logbody, where ) ):
+                    kf.write( "%s/%s.log %s\n" % (where, pkg_spec, problem.name) )
+
+            kf.close()
+        except IOError:
+            print "File error processing %s" % logpath
+
+    return( len(needs_kpr) )
+
 def process_section( section, config, problem_list ):
     """ Update .bug and .kpr files for logs in this section """
 
@@ -135,6 +172,10 @@ def process_section( section, config, problem_list ):
     del_cnt = clean_cache_files( logdict, kprdict )
     clean_cache_files( logdict, bugdict, True )
 
+    (kprdict, bugdict) = [get_file_dict(workdirs,x) for x in [KPR_EXT, BUG_EXT]]
+
+    add_cnt = make_kprs( logdict, kprdict, problem_list )
+
 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