-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist.py
38 lines (36 loc) · 1.25 KB
/
list.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
import os
import os.path
import json
rootdir = './TrafficTrace/'
fout = open ('timelines.csv', 'w')
title = "NO,APK_NAME,ACTIVITY,START,END,SPEEDINDEX,HAS WEBVIEW,WEBVIEW START,WEBVIEW END,URL\n"
fout.write(title)
cnt = 1
for dirname in os.listdir('./TrafficTrace'):
if dirname == ".DS_Store":
continue
print dirname
title = dirname
timeline = open('SpeedIndex/'+dirname+'.json')
timeline = json.load(timeline)
dirname = rootdir + dirname
url = open(dirname+'/url.txt').readline()
result = ""
for activity in timeline["times"]:
if "fullName" in activity and activity["fullName"] == "WebView":
result = result + ",yes," + str(activity["start"]) + "," + str(activity["end"]) + "," + url + "\n"
fout.write(result)
break
elif result != "" and "activity" in activity:
result = result + ",no,,,\n"
fout.write(result)
result = ",," + activity["activity"] + "," + str(activity["start"]) + "," + str(activity["end"]) + ","
if "speedindex" in activity:
result = result + str(activity["speedindex"]["SpeedIndex"])
else:
result = str(cnt) + "," + title + ","
if "activity" in activity:
result = result + activity["activity"]
result = result + "," + str(activity["start"]) + "," + str(activity["end"]) + ","
cnt = cnt + 1
fout.close()