forked from aragevorgyan/usbmon-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusbmon-parser.py
executable file
·48 lines (37 loc) · 985 Bytes
/
usbmon-parser.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
#!/usr/bin/python
import cmd
import os
import sys
import parser
class CLI(cmd.Cmd):
def __init__(self):
cmd.Cmd.__init__(self)
self.prompt = '>>> '
def do_hello(self, arg):
print "hello again", arg, "!"
def help_hello(self):
print "syntax: hello [message]",
print "-- prints a hello message"
def do_ls(self, arg):
print "ID\tDevice"
output = os.popen('lsusb').read()
array = output.splitlines()
for i in array[:]:
ID = int(i.split(' ')[1])
print "%du\t%s" % (ID, i)
#print output
def do_cat(self, arg):
path = "/sys/kernel/debug/usb/usbmon/" + arg
#print path
parser.run(path)
def do_quit(self, arg):
sys.exit(1)
def help_quit(self):
print "syntax: quit",
print "-- terminates the application"
# shortcuts
do_q = do_quit
#
# try it out
cli = CLI()
cli.cmdloop()