Created
May 5, 2012 13:39
-
-
Save eigenhombre/2602511 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
slurp.py | |
John Jacobsen, NPX Designs, Inc., john@mail.npxdesigns.com | |
Started: Sat May 5 07:55:34 2012 | |
""" | |
import os | |
import re | |
def abbrev(items): | |
ret = "" | |
for line in items: | |
tokens = line.split() | |
if tokens[0] == 'CnCServer': | |
ret += "C" | |
elif tokens[0] == 'dashlog': | |
ret += 'd' | |
elif tokens[0] == 'eventBuilder': | |
ret += 'E' | |
elif tokens[0] == 'globalTrigger': | |
ret += 'G' | |
elif tokens[0] == 'iceTopTrigger': | |
ret += 'T' | |
elif tokens[0] == 'inIceTrigger': | |
ret += 'I' | |
elif tokens[0] == 'secondaryBuilders': | |
ret += 'S' | |
elif tokens[0] == 'secondaryBuilders': | |
ret += 'S' | |
elif re.search('stringHub#(\d+)', tokens[0]): | |
ret += ' '+re.search('stringHub#(\d+)', tokens[0]).group(1) | |
else: | |
ret += '??%s ' % tokens[0] | |
return ret | |
def main(): | |
dikt = {} | |
path = '/Users/jacobsen/Desktop/detdbg/daqrun120082' | |
files = os.listdir(path) | |
for f in [f for f in files if f.endswith('.log')]: | |
lines = file(path+'/'+f).read().split('\n') | |
for l in lines: | |
# [2012-05-05 12:31:10.103] | |
m = re.search('(\d+-\d+-\d+ \d+:\d+:\d+)', l) | |
if m: | |
try: | |
dikt[m.group(1)].append(l) | |
except KeyError: | |
dikt[m.group(1)] = [l] | |
for k in sorted(dikt.keys()): | |
print k, len(dikt[k]), abbrev(dikt[k]) | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment