forked from pyload/pyload
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.py
More file actions
95 lines (71 loc) · 1.77 KB
/
debug.py
File metadata and controls
95 lines (71 loc) · 1.77 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
#coding:utf-8
import re
import InitHomeDir
from os import listdir
class Wrapper(object):
pass
def filter_info(line):
if "object at 0x" in line:
return False
elif " at line " in line:
return False
elif " <DownloadThread(" in line:
return False
elif "<class '" in line:
return False
elif "PyFile " in line:
return False
elif " <module '" in line:
return False
else:
return True
def appendName(lines, name):
test = re.compile("^[a-zA-z0-9]+ = ")
for i, line in enumerate(lines):
if test.match(line):
lines[i] = name+"."+line
return lines
def initReport():
reports = []
for f in listdir("."):
if f.startswith("debug_"):
reports.append(f)
for i, f in enumerate(reports):
print "%s. %s" % (i,f)
choice = raw_input("Choose Report: ")
report = reports[int(choice)]
f = open(report, "rb")
content = f.readlines()
content = [x.strip() for x in content if x.strip()]
frame = Wrapper()
plugin = Wrapper()
pyfile = Wrapper()
frame_c = []
plugin_c = []
pyfile_c = []
dest = None
for line in content:
if line == "FRAMESTACK:":
dest = frame_c
continue
elif line == "PLUGIN OBJECT DUMP:":
dest = plugin_c
continue
elif line == "PYFILE OBJECT DUMP:":
dest = pyfile_c
continue
elif line == "CONFIG:":
dest = None
if dest is not None:
dest.append(line)
frame_c = filter(filter_info, frame_c)
plugin_c = filter(filter_info, plugin_c)
pyfile_c = filter(filter_info, pyfile_c)
frame_c = appendName(frame_c, "frame")
plugin_c = appendName(plugin_c, "plugin")
pyfile_c = appendName(pyfile_c, "pyfile")
exec("\n".join(frame_c+plugin_c+pyfile_c) )
return frame, plugin, pyfile
if __name__=='__main__':
print "No main method, use this module with your python shell"