diff options
author | spoob <spoob@gmx.de> | 2010-01-10 03:22:04 +0100 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2010-01-10 03:22:04 +0100 |
commit | a1c1d16ab515373c6111724393a0b242e9bf32a4 (patch) | |
tree | 789635945c5a67881850774082f1c15389d4e61e /module | |
parent | better hook config (diff) | |
download | pyload-a1c1d16ab515373c6111724393a0b242e9bf32a4.tar.xz |
dont import deactivated hooks
Diffstat (limited to 'module')
-rw-r--r-- | module/HookManager.py | 24 | ||||
-rw-r--r-- | module/plugins/hooks/ContainerDownload.py | 2 | ||||
-rw-r--r-- | module/plugins/hooks/__init__.py | 1 |
3 files changed, 18 insertions, 9 deletions
diff --git a/module/HookManager.py b/module/HookManager.py index dc96d6d45..57b766201 100644 --- a/module/HookManager.py +++ b/module/HookManager.py @@ -19,6 +19,8 @@ """ import logging +from module.XMLConfigParser import XMLConfigParser + from os.path import basename, join from glob import glob @@ -27,6 +29,9 @@ from threading import Lock class HookManager(): def __init__(self, core): self.core = core + self.configParser = XMLConfigParser(join("module","config","plugin.xml")) + self.configParser.loadData() + self.config = self.configParser.getConfig() self.logger = logging.getLogger("log") self.plugins = [] self.lock = Lock() @@ -38,16 +43,21 @@ class HookManager(): plugins = [] for pluginFile in pluginFiles: pluginName = basename(pluginFile).replace(".py", "") - if pluginName == "Hook" or pluginName == "__init__": - continue
+ if pluginName == "__init__": + continue + if pluginName in self.config.keys(): + if not self.config[pluginName]["activated"]: + self.logger.info("Deactivated %s" % pluginName) + continue + else: + self.configParser.set(pluginName, {"option": "activated", "type": "bool", "name": "Activated"}, True)
module = __import__("module.plugins.hooks."+pluginName, globals(), locals(), [pluginName], -1) pluginClass = getattr(module, pluginName) plugin = pluginClass(self.core) - plugin.readConfig() - if plugin.isActivated(): - plugins.append(plugin) -
- self.logger.info("Installed Hook: %s" % pluginName) + plugin.setup() + plugins.append(plugin) + self.logger.info("Activated %s" % pluginName) + self.plugins = plugins self.lock.release() diff --git a/module/plugins/hooks/ContainerDownload.py b/module/plugins/hooks/ContainerDownload.py index c13a7f622..f520b705c 100644 --- a/module/plugins/hooks/ContainerDownload.py +++ b/module/plugins/hooks/ContainerDownload.py @@ -18,7 +18,7 @@ @interface-version: 0.1 """ -from module.plugins.hooks.Hook import Hook +from module.plugins.Hook import Hook from os.path import join, abspath diff --git a/module/plugins/hooks/__init__.py b/module/plugins/hooks/__init__.py index 8b1378917..e69de29bb 100644 --- a/module/plugins/hooks/__init__.py +++ b/module/plugins/hooks/__init__.py @@ -1 +0,0 @@ - |