-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlog-crunch.py
executable file
·34 lines (28 loc) · 1.12 KB
/
log-crunch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
# reads log.txt, extracts parmeters, and writes to CSV file out.txt
import re
log = open("log.txt", "r")
out = open("out.txt", "w")
for line in log:
if re.match("(.*)openscad(.*)", line):
if line[0] == ' ':
line = 'Z'+line;
line = line.replace(' ',' ') # compress spaces
line = line.replace(' ',' ') # compress spaces again
line = line.replace(': ',' ') # strip trailing colon
line = line.replace(' -D ',' ') # strip -D
line = line.replace(' -o ',' ') # strip -o
line = line.replace('echo " ','') # strip echo prefix/suffix
line = line.replace('" \| batch','')
line = line.replace('| batch','')
line = line.replace('e-NABLE/Assembly/Assembly.scad','')
line = line.replace('openscad','')
line = line.strip()
line = line.replace(' ',' ') # compress spaces (from where we removed a few things)
line = line.replace(' ',' ') # compress spaces again
line = line.replace(' ',',') # now make CSV
line = line.replace('=',',') # now make CSV
print line
out.write(line+"\n")
log.close()
out.close()