diff options
Diffstat (limited to 'pyload/manager')
-rw-r--r-- | pyload/manager/Account.py | 2 | ||||
-rw-r--r-- | pyload/manager/Addon.py | 58 | ||||
-rw-r--r-- | pyload/manager/Plugin.py | 11 |
3 files changed, 37 insertions, 34 deletions
diff --git a/pyload/manager/Account.py b/pyload/manager/Account.py index 2631e1c7d..12fc970c2 100644 --- a/pyload/manager/Account.py +++ b/pyload/manager/Account.py @@ -176,7 +176,7 @@ class AccountManager(object): if self.accounts[p]: p = self.getAccountPlugin(p) if p: - data[p.__name] = p.getAllAccounts(force) + data[p.__class__.__name__] = p.getAllAccounts(force) else: #@NOTE: When an account has been skipped, p is None data[p] = [] else: diff --git a/pyload/manager/Addon.py b/pyload/manager/Addon.py index 164068634..0bd51c943 100644 --- a/pyload/manager/Addon.py +++ b/pyload/manager/Addon.py @@ -71,7 +71,7 @@ class AddonManager(object): try: return func(*args) except Exception, e: - args[0].log.error(_("Error executing addon: %s") % e) + args[0].core.log.error(_("Error executing addon: %s") % e) if args[0].core.debug: traceback.print_exc() @@ -100,32 +100,32 @@ class AddonManager(object): def createIndex(self): plugins = [] - active = [] - deactive = [] - for pluginname in self.core.pluginManager.addonPlugins: - try: - # hookClass = getattr(plugin, plugin.__name) - if self.core.config.getPlugin(pluginname, "activated"): - pluginClass = self.core.pluginManager.loadClass("addon", pluginname) - if not pluginClass: - continue - - plugin = pluginClass(self.core, self) - plugins.append(plugin) - self.pluginMap[pluginClass.__name] = plugin - if plugin.isActivated(): - active.append(pluginClass.__name) - else: - deactive.append(pluginname) - - except Exception: - self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) - if self.core.debug: - traceback.print_exc() + for type in ("addon", "hook"): + active = [] + deactive = [] + for pluginname in getattr(self.core.pluginManager, "%sPlugins" % type): + try: + if self.core.config.getPlugin("%s_%s" % (pluginname, type), "activated"): + pluginClass = self.core.pluginManager.loadClass(type, pluginname) + if not pluginClass: + continue + + plugin = pluginClass(self.core, self) + plugins.append(plugin) + self.pluginMap[pluginClass.__name__] = plugin + if plugin.isActivated(): + active.append(pluginClass.__name__) + else: + deactive.append(pluginname) + + except Exception: + self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) + if self.core.debug or True: + traceback.print_exc() - self.core.log.info(_("Activated addons: %s") % ", ".join(sorted(active))) - self.core.log.info(_("Deactivated addons: %s") % ", ".join(sorted(deactive))) + self.core.log.info(_("Activated %ss: %s") % (type, ", ".join(sorted(active)))) + self.core.log.info(_("Deactivated %ss: %s") % (type, ", ".join(sorted(deactive)))) self.plugins = plugins @@ -141,7 +141,7 @@ class AddonManager(object): def activateAddon(self, pluginname): # check if already loaded for inst in self.plugins: - if inst.__name == pluginname: + if inst.__class__.__name__ == pluginname: return pluginClass = self.core.pluginManager.loadClass("addon", pluginname) @@ -153,14 +153,14 @@ class AddonManager(object): addon = pluginClass(self.core, self) self.plugins.append(addon) - self.pluginMap[pluginClass.__name] = addon + self.pluginMap[pluginClass.__name__] = addon addon.activate() def deactivateAddon(self, pluginname): for plugin in self.plugins: - if plugin.__name == pluginname: + if plugin.__class__.__name__ == pluginname: addon = plugin break else: @@ -174,7 +174,7 @@ class AddonManager(object): self.core.log.debug("Removed callback: %s" % self.core.scheduler.removeJob(addon.cb)) self.plugins.remove(addon) - del self.pluginMap[addon.__name] + del self.pluginMap[addon.__class__.__name__] @try_catch diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py index 72fabb33a..222ed9c93 100644 --- a/pyload/manager/Plugin.py +++ b/pyload/manager/Plugin.py @@ -55,12 +55,15 @@ class PluginManager(object): sys.path.append(abspath("")) self.loadTypes() + + configs = [] for type in self.TYPES: self.plugins[type] = self.parse(type) setattr(self, "%sPlugins" % type, self.plugins[type]) + configs.extend("%s_%s" % (p, type) for p in self.plugins[type]) - self.plugins['addon'] = self.addonPlugins.update(self.hookPlugins) + self.core.config.removeDeletedPlugins(configs) self.core.log.debug("Created index of plugins") @@ -143,7 +146,7 @@ class PluginManager(object): # internals have no config if folder == "internal": - self.core.config.deleteConfig(name) + self.core.config.deleteConfig("internal") continue config = self.CONFIG.findall(content) @@ -161,7 +164,7 @@ class PluginManager(object): if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]: config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True]) - self.core.config.addPluginConfig(name, config, desc) + self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc) except Exception: self.core.log.error("Invalid config in %s: %s" % (name, config)) @@ -171,7 +174,7 @@ class PluginManager(object): config = (["activated", "bool", "Activated", False],) try: - self.core.config.addPluginConfig(name, config, desc) + self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc) except Exception: self.core.log.error("Invalid config in %s: %s" % (name, config)) |