Files
openthread/tools/harness-automation/gencsv.py
T
Jonathan Hui f924adcb60 [style] update python style to conform to PEP 8 (#3951)
With the exception of line length set to 119 vs. 79.

Add tests/ and tools/ to py-pretty-check.
2019-07-11 11:45:55 -04:00

33 lines
690 B
Python
Executable File

#!/usr/bin/env python
import json
import sys
if len(sys.argv) > 1:
filename = sys.argv[1]
else:
filename = './result.json'
def get_key(item):
ds = item[0].split('_')
no = int(ds[1]) * 10000 + int(ds[2]) * 100 + int(ds[3])
ro = ds[0]
return '%d-%s' % (no, ro)
result = json.load(open(filename, 'r'))
o = open('./result.csv', 'w')
o.write('Case,Status,Started,Stopped,Reason\n')
for k, v in sorted(result.items(), key=get_key):
o.write(
'%s,%s,%s,%s,%s\n'
% (
k,
(v['passed'] and 'Pass') or 'Fail',
v['started'],
v['stopped'],
(v['error'] or '').replace('\n', ' '),
)
)