/usr/share/pyshared/numm/async_main.py is in python-numm 0.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | import sys
import traceback
import gio
import numm.async
def _load_module(path):
source = file(path).read()
code = compile(source, path, 'exec')
globals_dict = {}
exec code in globals_dict
return globals_dict
def _monitor_changes(path, cb):
def cb_(monitor, file, _other_file, event_type):
if event_type == gio.FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
cb()
monitor = gio.File(path).monitor()
monitor.connect('changed', cb_)
def print_errors(f):
def g(*a, **kw):
try:
f(*a, **kw)
except Exception:
traceback.print_exc()
return g
def main():
if len(sys.argv) < 2:
raise RuntimeError()
path = sys.argv[1]
sys.argv[1:] = sys.argv[2:]
run = numm.async.Run()
def load():
print 'load!'
module = _load_module(path)
for callback in numm.async.callbacks:
f = module.get(callback) or module.get(callback + 'put')
setter = getattr(run, 'set_' + callback, None)
if f is not None:
setter(print_errors(f))
else:
setter(None)
load()
_monitor_changes(path, load)
run.run()
|