diff options
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/Base.py | 4 | ||||
-rw-r--r-- | module/plugins/Hook.py | 2 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 2 | ||||
-rw-r--r-- | module/plugins/PluginManager.py | 41 | ||||
-rw-r--r-- | module/plugins/hooks/UpdateManager.py | 2 |
5 files changed, 27 insertions, 24 deletions
diff --git a/module/plugins/Base.py b/module/plugins/Base.py index b166ebae8..5a78fddc3 100644 --- a/module/plugins/Base.py +++ b/module/plugins/Base.py @@ -75,7 +75,7 @@ class Base(object): def setConf(self, option, value): """ see `setConfig` """ - self.core.config.setPlugin(self.__name__, option, value) + self.core.config.set(self.__name__, option, value) def setConfig(self, option, value): """ Set config value for current plugin @@ -88,7 +88,7 @@ class Base(object): def getConf(self, option): """ see `getConfig` """ - return self.core.config.getPlugin(self.__name__, option) + return self.core.config.get(self.__name__, option) def getConfig(self, option): """ Returns config value for current plugin diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index 5efd08bae..860dc76bb 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -119,7 +119,7 @@ class Hook(Base): def isActivated(self): """ checks if hook is activated""" - return self.config.getPlugin(self.__name__, "activated") + return self.config.get(self.__name__, "activated") #event methods - overwrite these if needed diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index b3c22f983..327e717a0 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -258,7 +258,7 @@ class Plugin(Base): temp_file.write(img) temp_file.close() - has_plugin = self.__name__ in self.core.pluginManager.captchaPlugins + has_plugin = self.__name__ in self.core.pluginManager.getPlugins("captcha") if self.core.captcha: Ocr = self.core.pluginManager.loadClass("captcha", self.__name__) diff --git a/module/plugins/PluginManager.py b/module/plugins/PluginManager.py index b1a82bcb6..9845590cf 100644 --- a/module/plugins/PluginManager.py +++ b/module/plugins/PluginManager.py @@ -27,12 +27,17 @@ from time import time from traceback import print_exc from module.lib.SafeEval import const_eval as literal_eval -from module.ConfigParser import IGNORE from module.plugins.Base import Base -from namedtuple import namedtuple +from new_collections import namedtuple -PluginTuple = namedtuple("PluginTuple", "version re desc long_desc deps user path") +# ignore these plugin configs, mainly because plugins were wiped out +IGNORE = ( + "FreakshareNet", "SpeedManager", "ArchiveTo", "ShareCx", ('hooks', 'UnRar'), + 'EasyShareCom', 'FlyshareCz' + ) + +PluginTuple = namedtuple("PluginTuple", "version re deps user path") class PluginManager: ROOT = "module.plugins." @@ -57,6 +62,9 @@ class PluginManager: self.history = [] # match history to speedup parsing (type, name) self.createIndex() + + self.core.config.parseValues(self.core.config.PLUGIN) + #register for import hook sys.meta_path.append(self) @@ -168,19 +176,23 @@ class PluginManager: plugin_re = None else: plugin_re = None + deps = attrs.get("dependencies", None) # create plugin tuple - plugin = PluginTuple(version, plugin_re, None, None, None, bool(home), filename) + plugin = PluginTuple(version, plugin_re, deps, bool(home), filename) # internals have no config if folder == "internal": - self.core.config.deleteConfig(name) return plugin + if folder == "hooks" and "config" not in attrs: + attrs["config"] = (["activated", "bool", "Activated", False],) + if "config" in attrs and attrs["config"]: config = attrs["config"] - desc = attrs["description"] if "description" in attrs else "" + desc = attrs.get("description", "") + long_desc = attrs.get("long_description", "") if type(config[0]) == tuple: config = [list(x) for x in config] @@ -193,21 +205,12 @@ class PluginManager: if item[0] == "activated": append = False # activated flag missing - if append: config.append(["activated", "bool", "Activated", False]) - - try: - self.core.config.addPluginConfig(name, config, desc) - except: - self.log.error("Invalid config in %s: %s" % (name, config)) - - elif folder == "hooks": #force config creation - desc = attrs["description"] if "description" in attrs else "" - config = (["activated", "bool", "Activated", False],) + if append: config.insert(0, ("activated", "bool", "Activated", False)) try: - self.core.config.addPluginConfig(name, config, desc) + self.core.config.addConfigSection(name, name, desc, long_desc, config) except: - self.log.error("Invalid config in %s: %s" % (name, config)) + self.logDebug(folder, name, "Invalid config %s" % config) return plugin @@ -294,7 +297,7 @@ class PluginManager: # convert path to python recognizable import path = basename(plugins[name].path).replace(".pyc", "").replace(".py", "") module = __import__(self.ROOT + "%s.%s" % (type, path), globals(), locals(), path) - self.modules[(type, name)] = module # cache import, maybne unneeded + self.modules[(type, name)] = module # cache import, maybe unneeded return module except Exception, e: self.log.error(_("Error importing %(name)s: %(msg)s") % {"name": name, "msg": str(e)}) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 8cbc56c42..4324a96ba 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -24,7 +24,7 @@ from os import stat from os.path import join, exists from time import time -from module.ConfigParser import IGNORE +from module.plugins.PluginManager import IGNORE from module.network.RequestFactory import getURL from module.plugins.Hook import threaded, Expose, Hook |