-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfpc-debug.py
executable file
·65 lines (54 loc) · 1.67 KB
/
fpc-debug.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
import argparse
import sys
import os
def getLogFiles() -> list:
fileList = []
for root, dirs, files in os.walk("./"):
for file in files:
if file.endswith(".fpc_log.txt"):
f = str(os.path.join(root, file))
fileList.append(f)
#print(f)
return fileList
def removeFiles(fileList: list):
for f in fileList:
print('Removing:', f)
os.remove(f)
def getCommandsStatus(fileList: list):
proc = 0
failed = 0
failed_list = []
for f in fileList:
with open(f, 'r') as fd:
for line in fd:
if line.startswith('Instrumented'):
proc += 1
elif line.startswith('Failed:'):
failed += 1
failed_list.append(line.split(':')[1].strip())
return proc, failed, failed_list
def report(proc: int, failed: int):
print('===== FPChcecker Report =====')
print('Processed files:', proc)
print('Failed:', failed)
def reportFailed(failed_list: list):
print('===== FPChcecker Report =====')
print('The following commnads failed:\n')
for l in failed_list:
print(l)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='FPChecker reporting tool')
parser.add_argument('-r', '--remove', action='store_true', help='Remove log files.')
parser.add_argument('-f', '--failed', action='store_true', help='Show commands that failed.')
args = parser.parse_args()
fileList = getLogFiles()
if len(sys.argv) > 1:
if args.remove:
removeFiles(fileList)
if args.failed:
_, _, failed_list = getCommandsStatus(fileList)
reportFailed(failed_list)
else:
proc, failed, _ = getCommandsStatus(fileList)
report(proc, failed)