-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogcat_analyzer.py
42 lines (36 loc) · 1.36 KB
/
logcat_analyzer.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
import os.path
import sys
import time
import subprocess
import webbrowser
from shutil import copyfile
from simple_analyzer import *
from simple_feedback import *
if __name__ == '__main__':
copyfile("template.html", "feedback.html")
pserver = subprocess.Popen(["python", "simple_server.py", "&"])
time.sleep(1)
webbrowser.open("http://localhost:8080/")
dataset_number = 0
lp = SimpleAnalyzer()
cmd = ["adb", "logcat"]
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
while True:
line = proc.stdout.readline()
if line.strip() != "":
result = lp.parse_line(line)
if result.strip() != "":
print result
time.sleep(0.02)
# if any returned number, the server got shut down and we can stop this program
if pserver.poll() is not None:
sys.exit()
# produce simple feedback file
sf = SimpleFeedback(lp.return_list(), lp.return_error(), "template.html", "fbtmp.html")
if not os.path.isfile("fbtmp.html"):
previous_dataset_number = dataset_number
dataset_number = sf.return_new_feedback(False, previous_dataset_number)
except KeyboardInterrupt:
sys.stdout.flush()
pass