Add parsing script
This commit is contained in:
parent
2e8fd407d4
commit
b4716b39da
1 changed files with 81 additions and 0 deletions
81
scripts/dcallan.py
Normal file
81
scripts/dcallan.py
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
import sys,os,functools,re
|
||||||
|
|
||||||
|
convert = {
|
||||||
|
"dcall-lightning-server-single": "donar",
|
||||||
|
"dcall-lightning-server": "donar",
|
||||||
|
"dcall-dup2-server-single": "torfone",
|
||||||
|
"dcall-dup2-server": "torfone",
|
||||||
|
"dcall-simple-server-single": "simple",
|
||||||
|
"dcall-simple-server": "simple"
|
||||||
|
}
|
||||||
|
|
||||||
|
def extract_info(inf, s):
|
||||||
|
try:
|
||||||
|
with open(inf) as f:
|
||||||
|
full = ''.join(f.readlines())
|
||||||
|
w = re.search(r'identifier=jan_dcall_(\w+)', full)
|
||||||
|
if not w: return False
|
||||||
|
s['current']['mode'] = w.groups()[0]
|
||||||
|
x = re.search(r'server= (\S+) \d+ ((\S+) (\d+))?', full)
|
||||||
|
if x:
|
||||||
|
s['current']['strat'] = convert[x.groups()[0]]
|
||||||
|
if x.groups()[2] != None:
|
||||||
|
y = re.search(r'tick_tock=(\d)', x.groups()[2])
|
||||||
|
if y:
|
||||||
|
s['current']['strat'] += "-default" if y.groups()[0] == '1' else "-double-send"
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
print("parse error for",inf)
|
||||||
|
return False
|
||||||
|
except Exception as e:
|
||||||
|
print("read error", inf, e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def categorize(f, s):
|
||||||
|
return True
|
||||||
|
|
||||||
|
def extract_dcall(f, s):
|
||||||
|
s['current']['success_buf'] = 0
|
||||||
|
s['current']['failed_buf'] = 0
|
||||||
|
try:
|
||||||
|
with open(f) as f:
|
||||||
|
for line in f:
|
||||||
|
time = line.split()[0]
|
||||||
|
minutes = int(time.split(':')[1])
|
||||||
|
if minutes <= 1 or minutes >= 13: continue
|
||||||
|
if 'Using buffer of size 160' in line:
|
||||||
|
s['current']['success_buf'] += 1
|
||||||
|
elif 'Using NULL buffer' in line:
|
||||||
|
s['current']['failed_buf'] += 1
|
||||||
|
print(s['current'])
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
print("read error", inf, e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def extract_folder(f, s):
|
||||||
|
return \
|
||||||
|
extract_info(f + '/info.txt', s) and \
|
||||||
|
extract_dcall(f + '/log/server-dcall-gstreamer.log', s)
|
||||||
|
|
||||||
|
def extract(p, s):
|
||||||
|
item_count = functools.reduce(lambda acc, prev: acc + 1, os.listdir(p), 0)
|
||||||
|
|
||||||
|
counter = 0
|
||||||
|
print("extracting...")
|
||||||
|
for folder in os.listdir(p):
|
||||||
|
s['current'] = { 'identifier': folder}
|
||||||
|
True and \
|
||||||
|
extract_folder(p + '/' + folder, s) and \
|
||||||
|
categorize(folder, s) or \
|
||||||
|
print(f"An error occured with {folder}")
|
||||||
|
counter += 1
|
||||||
|
progress = round(counter / item_count * 100)
|
||||||
|
print(f"{progress}%", end="\r")
|
||||||
|
print("done")
|
||||||
|
|
||||||
|
state = {'failure': {}, 'per_strat': {}, 'per_interval_res': {}, 'per_circuit_res': []}
|
||||||
|
extract(sys.argv[1], state)
|
||||||
|
print(state)
|
||||||
|
|
Loading…
Reference in a new issue