5 from PLC.Debug import log
8 from PLC.Plugins import PluginManager
9 pm = PluginManager(None, None)
11 pm.notify("who", {"what": "this!"})
15 def __init__(self, api, auth):
20 for entrypoint in pkg_resources.iter_entry_points("plcapi.plugin","api_notify"):
23 # pkg_resources looks for modules in sys.path. Make sure it can
25 sys.path.append("/usr/share/plc_api")
28 pluginclass = entrypoint.load()
29 plugin = pluginclass()
30 self.plugins.append(plugin)
31 except Exception, exc:
32 print >>log, "WARNING: failed to load plugin %s" % str(entrypoint)
33 traceback.print_exc(5,log)
37 def notify(self, action, info={}):
38 for plugin in self.plugins:
40 plugin.notify(self.api, self.auth, action, info)
41 except Exception, exc:
42 print >>log, "WARNING: failed to run plugin during action %s" % str(action)
43 traceback.print_exc(5,log)
46 for plugin in self.plugins:
47 print plugin.__class__.__name__