def _doDisablePlugin(self, result, name, plugin): #if not self.upnp_service.running == 0: # self.upnp_service.disownParent() if isinstance(plugin, UPNPDevice): self.upnp_service.unregisterUPNPDevice(plugin) conf.set(CORE_ENABLED_PLUGINS=[pname for pname,plugin in self._plugins.items() if plugin.running]) self.log_info("disabled plugin '%s'" % name)
def enablePlugin(self, name): """Enables the named plugin.""" try: if not name in self._plugins: raise Exception("plugin doesn't exist") if self.pluginIsEnabled(name): raise Exception("plugin is already enabled") plugin = self._plugins[name] # if plugin is a UPnP device, then check if the UPnP server is running if isinstance(plugin, UPNPDevice): # if it isn't, then start it if self.upnp_service.running == 0: # setServiceParent() implicitly calls startService() self.upnp_service.setServiceParent(self) if plugin.parent == None: plugin.setServiceParent(self.upnp_service) else: plugin.startService() # register UPNP device self.upnp_service.registerUPNPDevice(plugin) # otherwise plugin is a simple Service else: if plugin.parent == None: plugin.setServiceParent(self) else: plugin.startService() # update the list of enabled plugins conf.set(CORE_ENABLED_PLUGINS=[pname for pname,plugin in self._plugins.items() if plugin.running]) self.log_info("enabled plugin '%s'" % name) except Exception, e: self.log_error("failed to enable plugin '%s': %s" % (name, e))