From 33d6f212b2ee14f465fb3b3e650d783a76483fff Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 25 Feb 2014 07:56:48 -0800 Subject: [PATCH] beginning of a script to parse relay logs --- xwords4/scripts/log-parse.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 xwords4/scripts/log-parse.py diff --git a/xwords4/scripts/log-parse.py b/xwords4/scripts/log-parse.py new file mode 100755 index 000000000..e6d067e8e --- /dev/null +++ b/xwords4/scripts/log-parse.py @@ -0,0 +1,33 @@ +#!/usr/bin/python + +import sys, re + +LINE = re.compile('(<0x.*>)(\d\d:\d\d:\d\d): (.*)$') +DATE = re.compile('It\'s a new day: \d\d/\d\d/\d\d\d\d') +nMatches = 0 +nDates = 0 + +def handleLine(thread, timestamp, rest): + global nMatches + nMatches += 1 + print "handleLine got", thread, "and", timestamp, "and", rest + +def main(): + global nMatches, nDates + + for line in sys.stdin: + line.strip() + mtch = LINE.match(line) + if mtch: + handleLine( mtch.group(1), mtch.group(2), mtch.group(3) ) + break + mtch = DATE.match(line) + if mtch: + nDates += 1 + continue + print "unmatched: ", line + break + + print "got", nMatches, "normal lines and", nDates, "dates." + +main()