summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/HookManager.py22
-rw-r--r--module/plugins/hooks/Hook.py14
2 files changed, 15 insertions, 21 deletions
diff --git a/module/HookManager.py b/module/HookManager.py
index d2196ec4f..dc96d6d45 100644
--- a/module/HookManager.py
+++ b/module/HookManager.py
@@ -24,15 +24,9 @@ from glob import glob
from threading import Lock
-from module.XMLConfigParser import XMLConfigParser
-
-
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()
@@ -45,17 +39,13 @@ class HookManager():
for pluginFile in pluginFiles:
pluginName = basename(pluginFile).replace(".py", "")
if pluginName == "Hook" or pluginName == "__init__":
- continue
- if pluginName in self.config.keys():
- if not self.config[pluginName]["activated"]:
- continue
- else:
- self.configParser.set(pluginName, {"option": "activated", "type": "bool", "name": "Activated"}, True)
- module = __import__("module.plugins.hooks." + pluginName, globals(), locals(), [pluginName], -1)
+ continue
+ module = __import__("module.plugins.hooks."+pluginName, globals(), locals(), [pluginName], -1)
pluginClass = getattr(module, pluginName)
- pluginLoaded = pluginClass(self.core)
- pluginLoaded.setup()
- plugins.append(pluginLoaded)
+ plugin = pluginClass(self.core)
+ plugin.readConfig()
+ if plugin.isActivated():
+ plugins.append(plugin)
self.logger.info("Installed Hook: %s" % pluginName)
self.plugins = plugins
diff --git a/module/plugins/hooks/Hook.py b/module/plugins/hooks/Hook.py
index 4b5f6751f..1a7fba092 100644
--- a/module/plugins/hooks/Hook.py
+++ b/module/plugins/hooks/Hook.py
@@ -40,13 +40,17 @@ class Hook():
def readConfig(self):
self.configParser.loadData()
section = self.props['name']
- #~ try:
- #~ self.config = self.configParser.getConfig()[section]
- #~ except:
- #~ self.setup()
+ try:
+ self.config = self.configParser.getConfig()[section]
+ except:
+ self.setup()
def setup(self):
- pass
+ self.configParser.set(self.props["name"], {"option": "activated", "type": "bool", "name": "Activated"}, True)
+ self.readConfig()
+
+ def isActivated(self):
+ return self.config["activated"]
def downloadStarts(self, pyfile):
pass