def reloadplugin(self, name): """broken""" if not name in self.plugins: Log.error("Plugin %s not loaded" % name) return try: if "ondestroy" in dir(self.plugins[name]): self.plugins[name].ondestroy() Log.notice("%s Unloaded" % name) except Exception: Log.error("Cannot unload plugin %s" % name) Log.error("Use forceunload to remove it anyway") Log.error(traceback.print_exc()) try: code = reload(sys.modules[name]) except Exception: Log.error("Cannot reload plugin %s!" % name) return self.plugins.update([(name, code.Main())]) self.plugins[name].socket = self.app.tasclient.socket try: if "onload" in dir(self.plugins[name]): self.plugins[name].onload(self.app.tasclient) except Exception: Log.error("Cannot load plugin " + name) Log.error(traceback.print_exc()) return Log.loaded("Plugin " + name)
def unloadplugin(self, name): """ unload plugin, stop all its threads via ondestroy and remove from interal list""" if not name in self.plugins: Log.error("Plugin %s not loaded" % name) return try: if "ondestroy" in dir(self.plugins[name]): self.plugins[name].ondestroy() self.plugins.pop(name) Log.notice("%s Unloaded" % name) except Exception, e: Log.error("Cannot unload plugin %s" % name) Log.error("Use forceunload to remove it anyway") Log.exception(e)