[Piuparts-commits] [piuparts] 03/07: dwke: move some methods to piupartslib/dwke.py
Holger Levsen
holger at layer-acht.org
Tue Sep 12 11:59:20 UTC 2017
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch develop
in repository piuparts.
commit 806a3cb237e27605d093283ec3c374365c6ee4fb
Author: Andreas Beckmann <anbe at debian.org>
Date: Mon Sep 11 13:58:48 2017 +0200
dwke: move some methods to piupartslib/dwke.py
Signed-off-by: Andreas Beckmann <anbe at debian.org>
Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
master-bin/detect_well_known_errors.py | 63 ----------------------------------
piupartslib/dwke.py | 55 +++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 63 deletions(-)
diff --git a/master-bin/detect_well_known_errors.py b/master-bin/detect_well_known_errors.py
index c8f4307..c803c7f 100644
--- a/master-bin/detect_well_known_errors.py
+++ b/master-bin/detect_well_known_errors.py
@@ -59,69 +59,6 @@ def setup_logging(log_level):
logger.addHandler(handler)
-def write_file(filename, contents):
- with file(filename, "w") as f:
- f.write(contents)
-
-
-def mtime(path):
- return os.path.getmtime(path)
-
-
-def clean_cache_files(logdict, cachedict, recheck=False, recheck_failed=False,
- skipnewer=False):
- """Delete files in cachedict if the corresponding logdict file is missing
- or newer"""
-
- count = 0
- for pkgspec in cachedict:
- try:
- if pkgspec not in logdict \
- or (mtime(logdict[pkgspec]) > mtime(cachedict[pkgspec]) and not skipnewer)\
- or get_where(logdict[pkgspec]) != get_where(cachedict[pkgspec])\
- or recheck\
- or (recheck_failed and not get_where(cachedict[pkgspec]) in ['pass']):
- os.remove(cachedict[pkgspec])
- count = count + 1
- except (IOError, OSError):
- # logfile may have disappeared
- pass
-
- 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)
-
- kprs = ""
- for problem in problem_list:
- if problem.has_problem(logbody, where):
- kprs += "%s/%s.log %s\n" % (where, pkg_spec, problem.name)
-
- if not where in ['pass'] and not len(kprs):
- kprs += "%s/%s.log %s\n" % (where, pkg_spec, "unclassified_failures.conf")
-
- write_file(get_kpr_path(logpath), kprs)
- except IOError:
- logging.error("File error processing %s" % logpath)
-
- return len(needs_kpr)
-
-
def process_section(section, config, problem_list,
recheck=False, recheck_failed=False, pkgsdb=None):
""" Update .bug and .kpr files for logs in this section """
diff --git a/piupartslib/dwke.py b/piupartslib/dwke.py
index 4894ac2..3217ee1 100644
--- a/piupartslib/dwke.py
+++ b/piupartslib/dwke.py
@@ -224,4 +224,59 @@ def create_problem_list(pdir):
return plist
+
+def clean_cache_files(logdict, cachedict, recheck=False, recheck_failed=False,
+ skipnewer=False):
+ """Delete files in cachedict if the corresponding logdict file is missing
+ or newer"""
+
+ count = 0
+ for pkgspec in cachedict:
+ try:
+ if pkgspec not in logdict \
+ or (os.path.getmtime(logdict[pkgspec]) > os.path.getmtime(cachedict[pkgspec]) and not skipnewer)\
+ or get_where(logdict[pkgspec]) != get_where(cachedict[pkgspec])\
+ or recheck\
+ or (recheck_failed and not get_where(cachedict[pkgspec]) in ['pass']):
+ os.remove(cachedict[pkgspec])
+ count = count + 1
+ except (IOError, OSError):
+ # logfile may have disappeared
+ pass
+
+ 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)
+
+ kprs = ""
+ for problem in problem_list:
+ if problem.has_problem(logbody, where):
+ kprs += "%s/%s.log %s\n" % (where, pkg_spec, problem.name)
+
+ if not where in ['pass'] and not len(kprs):
+ kprs += "%s/%s.log %s\n" % (where, pkg_spec, "unclassified_failures.conf")
+
+ with open(get_kpr_path(logpath), 'w') as f:
+ f.write(kprs)
+ except IOError:
+ logging.error("File error processing %s" % logpath)
+
+ return len(needs_kpr)
+
# vi:set et ts=4 sw=4 :
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git
More information about the Piuparts-commits
mailing list