-
Notifications
You must be signed in to change notification settings - Fork 1
/
usbmon-parser.py
executable file
·55 lines (42 loc) · 1.08 KB
/
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
49
50
51
52
53
54
55
#!/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_parse(self,arg):
parser.run(arg)
def do_frequency(self,arg):
parser.frequency(arg)
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
print "Starting CLI"
cli = CLI()
cli.cmdloop()