1 import string
2
3
4
5
6
8 """
9 API to interact with the "database" storing information
10 for the zbscanning program.
11 """
12
14 self.channels = {11:None, 12:None, 13:None, 14:None, 15:None, 16:None, 17:None, 18:None, 19:None, 20:None, 21:None, 22:None, 23:None, 24:None, 25:None, 26:None}
15
16 self.devices = {}
17
20
21
23 self.devices[devid] = (devstr, devserial, 'Free', None)
24
25
26
28 for devid, dev in self.devices.items():
29 if dev[2] == 'Free':
30 return devid
31
33 if devid not in self.devices:
34 return None
35 (devstr, devserial, _, chan) = self.devices[devid]
36 self.devices[devid] = (devstr, devserial, newstatus, chan)
37
39 if devid not in self.devices:
40 return None
41 (devstr, devserial, _, _) = self.devices[devid]
42 self.devices[devid] = (devstr, devserial, "Capture", channel)
43
44
46 if channel not in self.channels:
47 return None
48
49 self.channels[channel] = (key, spanid, source, packet)
50
51
52
54
55 for chan, data in self.channels:
56 if data[0] == key: return chan
57 return None
58
60 '''
61 Returns False if we have not seen the network or are not currently
62 logging it's channel, and returns True if we are currently logging it.
63 @return boolean
64 '''
65 if chan == None: raise Exception("None given for channel number")
66 elif chan not in self.channels: raise Exception("Invalid channel")
67 for dev in self.devices.values():
68 if dev[3] == chan and dev[2] == 'Capture':
69 return True
70 return False
71
72
74 return ''.join(["%02x" % ord(x) for x in bin])
75