Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
loader.py
Go to the documentation of this file.
1 import imp
2 import webiopi.utils.logger as logger
3 import webiopi.utils.thread as thread
4 SCRIPTS = {}
5 
6 def loadScript(name, source, handler = None):
7  logger.info("Loading %s from %s" % (name, source))
8  script = imp.load_source(name, source)
9  SCRIPTS[name] = script
10 
11  if hasattr(script, "setup"):
12  script.setup()
13  if handler:
14  for aname in dir(script):
15  attr = getattr(script, aname)
16  if callable(attr) and hasattr(attr, "macro"):
17  handler.addMacro(attr)
18  if hasattr(script, "loop"):
19  thread.runLoop(script.loop, True)
20 
22  for name in SCRIPTS:
23  script = SCRIPTS[name]
24  if hasattr(script, "destroy"):
26 
def destroy
Definition: script.py:28
def setup
Definition: script.py:15