[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. eda668423fa87898c59d1075118693714aa5a053

Mika Pflüger debian at mikapflueger.de
Fri Dec 23 10:25:03 UTC 2011


The following commit has been merged in the master branch:
commit f5f71cace376d60fb4f2a89c485c9c71eaf3342e
Author: Mika Pflüger <mika at mikapflueger.de>
Date:   Thu Jul 28 12:35:08 2011 +0200

    piuparts-analyze.py: rewrite extract_errors to behave like 'grep -i error'
    
    This is pretty stupid behaviour, but better than the old one which
    matched lines with the verison number of the package and (worse) the
    download speed of apt.
    Also adds the removal of chroot temp name and package version from error lines.

diff --git a/piuparts-analyze.py b/piuparts-analyze.py
index 15ad1d5..81907cb 100644
--- a/piuparts-analyze.py
+++ b/piuparts-analyze.py
@@ -34,7 +34,8 @@ import shutil
 import sys
 
 
-error_pattern = re.compile(r"(?<=\n)(\d+m\d+\.\d+s ERROR: .*\n(  .*\n)*\n?)+")
+error_pattern = re.compile(r"(?<=\n).*error.*\n?", flags=re.IGNORECASE)
+chroot_pattern = re.compile(r"tmp/tmp.*?'")
 
 
 def find_logs(dir):
@@ -53,23 +54,25 @@ def find_bugged_logs(failed_log):
 
 
 def extract_errors(log):
-    f = file(log, "r")
+    """This pretty stupid implementation is basically just 'grep -i error', and then
+    removing the timestamps and the name of the chroot and the package version itself."""
+    f = open(log)
     data = f.read()
     f.close()
-    m = error_pattern.search(data)
-    if m:
-        text = m.group()
+    whole = ''
+    pversion = package_version(log)
+    for match in error_pattern.finditer(data):
+        text = match.group()
         # Get rid of timestamps
-        text2 = []
-        for line in text.split("\n"):
-            if line[:1].isdigit():
-                text2.append(line.split(" ", 1)[1])
-            else:
-                text2.append(line)
-        return "\n".join(text2)
-    else:
-        return None
-
+        if text[:1].isdigit():
+            text = text.split(" ", 1)[1]
+        # Get rid of chroot names
+        if 'tmp/tmp' in text:
+            text = re.sub(chroot_pattern, "chroot'", text)
+        # Get rid of the package version
+        text = text.replace(pversion, '')
+        whole += text
+    return whole
 
 def extract_headers(log):
     f = file(log, "r")

-- 
piuparts git repository



More information about the Piuparts-commits mailing list