| 1 |
"""This script *replaces* the processlog.csh shell script. It has |
| 2 |
more sophisticated logic to add the etc test name to the pysynphot |
| 3 |
command as another keyword-value pair. |
| 4 |
|
| 5 |
Modified to parse the modified line, then write a dictionary that will |
| 6 |
be read by the gencases tool. |
| 7 |
""" |
| 8 |
|
| 9 |
import sys,re, pickle |
| 10 |
from pysynphot import etc |
| 11 |
import gencases |
| 12 |
|
| 13 |
def run(fname): |
| 14 |
log=open(fname) |
| 15 |
out=open(fname.replace('.txt','_lookup.pickle'),'w') |
| 16 |
d={} |
| 17 |
|
| 18 |
line='unopened' |
| 19 |
while len(line)>0: |
| 20 |
line = log.readline().strip() |
| 21 |
if "] starting" in line or "] running" in line: |
| 22 |
x=re.search("'(?P<name>.*)'",line) |
| 23 |
testname=x.group('name') |
| 24 |
elif 'command is' in line: |
| 25 |
prefix,value=line.lstrip().split('command is') |
| 26 |
cmd='%s&etcid="%s"\n'%(value[0:-2], |
| 27 |
testname) |
| 28 |
|
| 29 |
ktuple=gencases.line2ktuple(cmd) |
| 30 |
try: |
| 31 |
d[ktuple].append(testname) |
| 32 |
except KeyError: |
| 33 |
d[ktuple]=[testname] |
| 34 |
|
| 35 |
log.close() |
| 36 |
|
| 37 |
pickle.dump(d,out) |
| 38 |
out.close() |
| 39 |
|
| 40 |
if __name__ == '__main__': |
| 41 |
run(sys.argv[1]) |