-
Notifications
You must be signed in to change notification settings - Fork 5
/
usbmonparser.py
executable file
·58 lines (51 loc) · 1.01 KB
/
usbmonparser.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
#!/usr/bin/python
import sys
class parser:
def __init__(self,path):
f = open(path)
self.string = f.readlines()
self.clean()
self.Strip()
self.Print()
def clean(self):
tmp = []
for l in xrange(len(self.string)):
if " " in self.string[l]:
tmp.append(self.string[l])
self.string = tmp
def Strip(self):
for l in range(len(self.string)):
self.string[l] = self.string[l].strip()
for l in range(len(self.string)):
tmp = ""
for i in self.string[l]:
if i != " ":
tmp += i
self.string[l] = tmp
tmp = []
for l in self.string:
try:
int(l,16)
tmp.append(l)
except:
pass
self.string = tmp
def Print(self):
for l in range(len(self.string)):
n = 0
tmp = ""
for i in self.string[l]:
if n == 1:
n = 0
tmp += "%s "%i
else:
tmp += i
n += 1
self.string[l] = tmp
for l in self.string:
print l
if __name__ == "__main__":
if len(sys.argv) == 2:
pa = parser(sys.argv[1])
else:
print "Usage : usbmonparser.py [File]"