-
Notifications
You must be signed in to change notification settings - Fork 2
/
bluebox.py
executable file
·59 lines (48 loc) · 1.73 KB
/
bluebox.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
#!/usr/bin/python
import basics
import scheduler
import threading
import sys
import time
class Bluebox:
def __init__(self):
pass
def __del__(self):
pass
def main(self, args):
# behaviours: (event[a], rule[b]) -> action[a,b]
# when an 'event' happens and a 'rule' is loaded, the 'action' is called
behaviours = {
'newscan': ['deliverfile','postsighting','startextension'],
'obexin': ['acceptfile'],
'newruleslist': ['scan','advertise']
}
prefixrules = [('intelligentrules', 'True')]
# preactions: [('action',[argument1, argument2])]
# actions called before the rules file loaded
preactions = [
('dontscan', []),
('dontadvertise', [])
]
# postactions: [('action',[argument1, argument2])]
# actions called after the rules file loaded
postactions = []
sched = scheduler.Scheduler(behaviours=behaviours, rulesfile='defaultrules.yml', preactions=preactions, postactions=postactions, prefixrules=prefixrules)
sched.start()
try:
while 1:
time.sleep(1)
#print " bluebox is still alive ^^"
#print " rules:",sched.rules
#print " events:",shed.listEvents()
#print " devices:",sched.modules['scanner'].knownDevices.list()
time.sleep(10)
print "BlueBox terminated."
sys.exit(0)
except KeyboardInterrupt:
print "KILL SIGNAL RECEIVED"
sched.kill()
print "BlueBox terminated (forced)."
exit(1)
if __name__ == '__main__':
Bluebox().main(sys.argv)