From: Michael Andres Date: Fri, 4 Nov 2011 12:44:25 +0000 (+0100) Subject: zypper-log: fix regex and on the fly support searching yast logs too X-Git-Tag: 1.6.17~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=150897085ec62c7422a2844356b7bb186bcd6d39;p=platform%2Fupstream%2Fzypper.git zypper-log: fix regex and on the fly support searching yast logs too --- diff --git a/tools/zypper-log b/tools/zypper-log index 9d6bb03..523966f 100755 --- a/tools/zypper-log +++ b/tools/zypper-log @@ -44,20 +44,34 @@ def readFile(logfile): def getListFromLogFiles(logfiles): logindex = [] global pidlen, verlen - c = re.compile(r"===== Hi, me zypper (\d+.\d+.\d+)\s(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).+\((\d+)\).+=====\s(.+)\s=====") + # ===== Hi, me zypper 1.5.7 + # ===== Hi, me zypper 1.5.7 built Jul 28 2011 17:19:50 ===== + # genericfrontend.cc(main):675 Launched YaST2 component 'y2base' 'installation' '("continue")' 'qt' + c = re.compile(r"===== Hi, me zypper (\d+.\d+.\d+).*$\s(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).+\((\d+)\).+=====\s(.+)\s=====|genericfrontend.cc.*Launched (YaST2) component (.*)$\s(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}).+\((\d+)\)", re.M) for logfile in logfiles: print >> sys.stderr, "Reading %s" % logfile, '.' * (filenamelen - len(logfile) + 3), sys.stderr.flush() for run in c.findall(readFile(logfile)): - if len(run[2]) > pidlen: - pidlen = len(run[2]) - if len(run[0]) > verlen: - verlen = len(run[0]) - logindex.append({'version': run[0], - 'time': time.strptime(run[1], "%Y-%m-%d %H:%M:%S"), - 'pid': run[2], - 'cmd': run[3].replace("'", "")}) + if run[4] == 'YaST2': + ver = run[4] + tim = run[6] + pid = run[7] + cmd = run[5] + else: + ver = run[0] + tim = run[1] + pid = run[2] + cmd = run[3] + + if len(pid) > pidlen: + pidlen = len(pid) + if len(ver) > verlen: + verlen = len(ver) + logindex.append({'version': ver, + 'time': time.strptime(tim, "%Y-%m-%d %H:%M:%S"), + 'pid': pid, + 'cmd': cmd.replace("'", "")}) print >> sys.stderr, "DONE" sys.stderr.flush() print >> sys.stderr, ""