From a1c1d16ab515373c6111724393a0b242e9bf32a4 Mon Sep 17 00:00:00 2001 From: spoob Date: Sun, 10 Jan 2010 03:22:04 +0100 Subject: dont import deactivated hooks --- module/HookManager.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'module/HookManager.py') 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() -- cgit v1.2.3