diff options
author | spoob <spoob@gmx.de> | 2010-01-09 22:05:15 +0100 |
---|---|---|
committer | spoob <spoob@gmx.de> | 2010-01-09 22:05:15 +0100 |
commit | ad532495edc4103129bf86b53dec81038babe063 (patch) | |
tree | cc7aaa1b3a7dada6bd75699e8c4ef180ac148e86 | |
parent | Hooks can set Attributes (diff) | |
download | pyload-ad532495edc4103129bf86b53dec81038babe063.tar.xz |
Hooks Config Incomplete
-rw-r--r-- | module/HookManager.py | 19 | ||||
-rw-r--r-- | module/XMLConfigParser.py | 7 | ||||
-rw-r--r-- | module/config/core_default.xml | 1 | ||||
-rw-r--r-- | module/config/gui_default.xml | 1 | ||||
-rw-r--r-- | module/config/plugin_default.xml | 1 | ||||
-rw-r--r-- | module/plugins/hooks/Hook.py | 8 |
6 files changed, 26 insertions, 11 deletions
diff --git a/module/HookManager.py b/module/HookManager.py index a0caae728..d2196ec4f 100644 --- a/module/HookManager.py +++ b/module/HookManager.py @@ -24,9 +24,15 @@ 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() @@ -39,10 +45,17 @@ class HookManager(): for pluginFile in pluginFiles: pluginName = basename(pluginFile).replace(".py", "") if pluginName == "Hook" or pluginName == "__init__": - continue
- module = __import__("module.plugins.hooks."+pluginName, globals(), locals(), [pluginName], -1) + 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) pluginClass = getattr(module, pluginName) - plugins.append(pluginClass(self.core)) + pluginLoaded = pluginClass(self.core) + pluginLoaded.setup() + plugins.append(pluginLoaded) self.logger.info("Installed Hook: %s" % pluginName) self.plugins = plugins diff --git a/module/XMLConfigParser.py b/module/XMLConfigParser.py index 5f58c834b..678338b41 100644 --- a/module/XMLConfigParser.py +++ b/module/XMLConfigParser.py @@ -48,6 +48,7 @@ class XMLConfigParser(): if not self.xml.documentElement.getAttribute("version") == self.version: print "Cant Update %s" % self.file exit() #ok? + self.root = self.xml.documentElement self._read_config() def _copyConfig(self): @@ -115,7 +116,6 @@ class XMLConfigParser(): if opt.nodeType == opt.ELEMENT_NODE: if data["option"] == opt.tagName: replace = opt - self._setAttributes(node, data) text = self.xml.createTextNode(str(value)) if replace: replace.replaceChild(text, replace.firstChild) @@ -128,13 +128,12 @@ class XMLConfigParser(): newSection = self.xml.createElement(section) newSection.appendChild(newNode) root.appendChild(newSection) - self._setAttributes(newSection, data) + self._setAttributes(section, data) self.saveData() self.loadData() def _setAttributes(self, node, data): - node.setAttribute("name", node.tagName) - option = node.getElementsByTagName(data["option"])[0] + option = self.root.getElementsByTagName(node)[0].getElementsByTagName(data["option"])[0] option.setAttribute("name", data["name"]) option.setAttribute("type", data["type"]) try: diff --git a/module/config/core_default.xml b/module/config/core_default.xml index 07d4ddc1c..0d684890a 100644 --- a/module/config/core_default.xml +++ b/module/config/core_default.xml @@ -1,3 +1,4 @@ +<?xml version="1.0" ?> <config name="Configuration" version="0.1"> <remote name="Remote"> <port type="int" name="Port">7227</port> diff --git a/module/config/gui_default.xml b/module/config/gui_default.xml index 9b6d75936..490af199e 100644 --- a/module/config/gui_default.xml +++ b/module/config/gui_default.xml @@ -1,3 +1,4 @@ +<?xml version="1.0" ?> <root> <connections> <connection default="True" type="local" id="33965310e19b4a869112c43b39a16440"> diff --git a/module/config/plugin_default.xml b/module/config/plugin_default.xml index 3f033fc04..773e4e46f 100644 --- a/module/config/plugin_default.xml +++ b/module/config/plugin_default.xml @@ -1,3 +1,4 @@ +<?xml version="1.0" ?> <config name="Configuration" version="0.1"> <RapidshareCom> <server input=";Cogent;Deutsche Telekom;Level(3);Level(3) #2;GlobalCrossing;Level(3) #3;Teleglobe;GlobalCrossing #2;TeliaSonera #2;Teleglobe #2;TeliaSonera #3;TeliaSonera"></server> diff --git a/module/plugins/hooks/Hook.py b/module/plugins/hooks/Hook.py index 739af3200..4b5f6751f 100644 --- a/module/plugins/hooks/Hook.py +++ b/module/plugins/hooks/Hook.py @@ -40,10 +40,10 @@ 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 |