Save intermediate logs

Signed-off-by: Junjie Mao <eternal.n08@gmail.com>
This commit is contained in:
Junjie Mao
2015-03-12 16:05:28 +08:00
parent 67f05c0ce0
commit 1d8c85670d
12 changed files with 116 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env python
#
# Note: This script is intended to be executed at labcodes/labX
import sys, os
import re
if len(sys.argv) < 2:
print 'Usage: split_score_log.py <raw log file> <lab>'
sys.exit()
raw_log_f = sys.argv[1]
test_entry_title = re.compile('^([\w][\w -]+): *\([0-9.]*s\)')
raw_log = open(raw_log_f, 'r')
current_test = ''
for line in raw_log.readlines():
line = line.strip('\n')
m = test_entry_title.match(line)
if m:
print line
current_test = m.group(1)
error_log = open('.' + current_test.lower().replace(' ', '_') + '.error', 'w+')
print >> error_log, line
continue
if (not line or line[0] == ' ') and current_test != '':
print >> error_log, line
if (line and line[0] != ' ') or line.find('-check') >= 0:
print line