]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/pythonmod/doc/examples/example0-1.py
3b234f1e099c513c5e83fb496627157dfa10ddbc
[apple/network_cmds.git] / unbound / pythonmod / doc / examples / example0-1.py
1
2 def init(id, cfg):
3 log_info("pythonmod: init called, module id is %d port: %d script: %s" % (id, cfg.port, cfg.python_script))
4 return True
5
6 def deinit(id):
7 log_info("pythonmod: deinit called, module id is %d" % id)
8 return True
9
10 def inform_super(id, qstate, superqstate, qdata):
11 return True
12
13 def operate(id, event, qstate, qdata):
14 log_info("pythonmod: operate called, id: %d, event:%s" % (id, strmodulevent(event)))
15
16 if event == MODULE_EVENT_NEW:
17 qstate.ext_state[id] = MODULE_WAIT_MODULE
18 return True
19
20 if event == MODULE_EVENT_MODDONE:
21 log_info("pythonmod: module we are waiting for is done")
22 qstate.ext_state[id] = MODULE_FINISHED
23 return True
24
25 if event == MODULE_EVENT_PASS:
26 log_info("pythonmod: event_pass")
27 qstate.ext_state[id] = MODULE_ERROR
28 return True
29
30 log_err("pythonmod: BAD event")
31 qstate.ext_state[id] = MODULE_ERROR
32 return True
33
34 log_info("pythonmod: script loaded.")