-
Notifications
You must be signed in to change notification settings - Fork 5
/
split_pkt.py
executable file
·66 lines (57 loc) · 1.6 KB
/
split_pkt.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
59
60
61
62
63
64
65
66
#!/usr/bin/python
"""
Break out a packet for debugging
"""
from insteonrf.split_pkt import dump_pkt
from insteonrf.extract_dat_ln import extract_dat
import sys
import traceback
def readfromfile(filen) :
print "\n===========\n"
print filen
try :
Sout = extract_dat(filen)
except IndexError, err:
print "Extract failed :\n\t", filen, "\n\t", err
return
dump_pkt(Sout)
def main():
if len(sys.argv) == 1 or sys.argv[1] == "-":
while True:
try:
sys.stdout.flush()
line = sys.stdin.readline()
# print len(line)
if line.startswith("#"):
continue
line.strip()
print "line :", len(line)
print line
if len(line) == 1:
continue
if not line:
# print "Not Line"
exit(0)
dump_pkt(line)
sys.stdout.flush()
except KeyboardInterrupt:
break
except Exception, err:
print "Extract Failed :"
print " ", err
print '-'*60
traceback.print_exc(file=sys.stdout)
print '-'*60
raise
else:
for av in sys.argv[1:]:
try:
readfromfile(av)
except Exception, err:
print "Extract Failed :"
print " ", av
print " ", err
raise
if __name__ == "__main__":
main()
exit(0)