diff options
Diffstat (limited to 'pyload/manager')
-rw-r--r-- | pyload/manager/AccountManager.py | 4 | ||||
-rw-r--r-- | pyload/manager/AddonManager.py | 22 | ||||
-rw-r--r-- | pyload/manager/PluginManager.py | 37 | ||||
-rw-r--r-- | pyload/manager/ThreadManager.py | 23 |
4 files changed, 39 insertions, 47 deletions
diff --git a/pyload/manager/AccountManager.py b/pyload/manager/AccountManager.py index 3de656376..4e9e36cee 100644 --- a/pyload/manager/AccountManager.py +++ b/pyload/manager/AccountManager.py @@ -79,7 +79,7 @@ class AccountManager: return except IOError, e: - self.logError(e) + self.core.log.error(str(e)) return plugin = "" @@ -129,7 +129,7 @@ class AccountManager: chmod(f.name, 0600) except Exception, e: - self.logError(e) + self.core.log.error(str(e)) #---------------------------------------------------------------------- diff --git a/pyload/manager/AddonManager.py b/pyload/manager/AddonManager.py index 34952e026..5ad62f515 100644 --- a/pyload/manager/AddonManager.py +++ b/pyload/manager/AddonManager.py @@ -62,12 +62,8 @@ class AddonManager: """ def __init__(self, core): - self.core = core - self.config = self.core.config - __builtin__.addonManager = self #needed to let addons register themself - self.log = self.core.log self.plugins = [] self.pluginMap = {} self.methods = {} #dict of names and list of methods usable by rpc @@ -75,7 +71,7 @@ class AddonManager: self.events = {} # contains events #registering callback for config event - self.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) + self.core.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) self.addEvent("pluginConfigChanged", self.manageAddon) @@ -123,7 +119,7 @@ class AddonManager: try: # hookClass = getattr(plugin, plugin.__name__) - if self.config.getPlugin(pluginname, "activated"): + if self.core.config.getPlugin(pluginname, "activated"): pluginClass = self.core.pluginManager.loadClass("addon", pluginname) if not pluginClass: continue @@ -137,12 +133,12 @@ class AddonManager: except: - self.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) + self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) if self.core.debug: traceback.print_exc() - self.log.info(_("Activated addons: %s") % ", ".join(sorted(active))) - self.log.info(_("Deactivated addons: %s") % ", ".join(sorted(deactive))) + self.core.log.info(_("Activated addons: %s") % ", ".join(sorted(active))) + self.core.log.info(_("Deactivated addons: %s") % ", ".join(sorted(deactive))) self.plugins = plugins @@ -163,7 +159,7 @@ class AddonManager: if not pluginClass: return - self.log.debug("Plugin loaded: %s" % plugin) + self.core.log.debug("Plugin loaded: %s" % plugin) plugin = pluginClass(self.core, self) self.plugins.append(plugin) @@ -182,12 +178,12 @@ class AddonManager: if not addon: return - self.log.debug("Plugin unloaded: %s" % plugin) + self.core.log.debug("Plugin unloaded: %s" % plugin) addon.unload() #remove periodic call - self.log.debug("Removed callback %s" % self.core.scheduler.removeJob(addon.cb)) + self.core.log.debug("Removed callback %s" % self.core.scheduler.removeJob(addon.cb)) self.plugins.remove(addon) del self.pluginMap[addon.__name__] @@ -300,7 +296,7 @@ class AddonManager: try: f(*args) except Exception, e: - self.log.warning("Error calling event handler %s: %s, %s, %s" + self.core.log.warning("Error calling event handler %s: %s, %s, %s" % (event, f, args, str(e))) if self.core.debug: traceback.print_exc() diff --git a/pyload/manager/PluginManager.py b/pyload/manager/PluginManager.py index c4c220af8..f91279d77 100644 --- a/pyload/manager/PluginManager.py +++ b/pyload/manager/PluginManager.py @@ -26,9 +26,6 @@ class PluginManager: def __init__(self, core): self.core = core - self.config = core.config - self.log = core.log - self.plugins = {} self.createIndex() @@ -47,7 +44,7 @@ class PluginManager: self.plugins['addon'] = self.addonPlugins.extend(self.hookPlugins) - self.log.debug("Created index of plugins") + self.core.log.debug("Created index of plugins") def parse(self, folder, rootplugins={}): @@ -71,7 +68,7 @@ class PluginManager: f.close() except IOError, e: - self.logCritical(e) + self.core.log.critical(str(e)) return rootplugins else: @@ -86,7 +83,7 @@ class PluginManager: content = data.read() except IOError, e: - self.logError(e) + self.core.log.error(str(e)) continue if f.endswith("_25.pyc") and version_info[0:2] != (2, 5): #@TODO: Remove in 0.4.10 @@ -129,7 +126,7 @@ class PluginManager: try: regexp = re.compile(pattern) except: - self.log.error(_("%s has a invalid pattern") % name) + self.core.log.error(_("%s has a invalid pattern") % name) pattern = r'^unmatchable$' regexp = re.compile(pattern) @@ -156,9 +153,9 @@ class PluginManager: if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]: config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True]) - self.config.addPluginConfig(name, config, desc) + self.core.config.addPluginConfig(name, config, desc) except: - self.log.error("Invalid config in %s: %s" % (name, config)) + self.core.log.error("Invalid config in %s: %s" % (name, config)) elif folder in ("addon", "hook"): #force config creation desc = self.DESC.findall(content) @@ -166,9 +163,9 @@ class PluginManager: config = (["activated", "bool", "Activated", False],) try: - self.config.addPluginConfig(name, config, desc) + self.core.config.addPluginConfig(name, config, desc) except: - self.log.error("Invalid config in %s: %s" % (name, config)) + self.core.log.error("Invalid config in %s: %s" % (name, config)) if not rootplugins and plugins: #: Double check plugins.update(self.parse(folder, plugins)) @@ -195,7 +192,7 @@ class PluginManager: try: m = value['re'].match(url) except KeyError: - self.log.error("Plugin %s skipped due broken pattern" % name) + self.core.log.error("Plugin %s skipped due broken pattern" % name) m = None if m: @@ -222,7 +219,7 @@ class PluginManager: plugin, type = self.findPlugin(name) if not plugin: - self.log.warning("Plugin %s not found" % name) + self.core.log.warning("Plugin %s not found" % name) plugin = self.hosterPlugins['BasePlugin'] if "new_module" in plugin and not original: @@ -257,7 +254,7 @@ class PluginManager: plugins[name]['name']) except Exception, e: - self.log.error(_("Error importing plugin: [%(type)s] %(name)s (v%(version).2f) | %(errmsg)s") + self.core.log.error(_("Error importing plugin: [%(type)s] %(name)s (v%(version).2f) | %(errmsg)s") % {'name': name, 'type': type, 'version': plugins[name]['version'], "errmsg": str(e)}) if self.core.debug: print_exc() @@ -265,7 +262,7 @@ class PluginManager: else: plugins[name]['module'] = module #: cache import, maybe unneeded - self.log.debug(_("Loaded plugin: [%(type)s] %(name)s (v%(version).2f)") + self.core.log.debug(_("Loaded plugin: [%(type)s] %(name)s (v%(version).2f)") % {'name': name, 'type': type, 'version': plugins[name]['version']}) return module @@ -315,7 +312,7 @@ class PluginManager: base, plugin = newname.rsplit(".", 1) - self.log.debug("Redirected import %s -> %s" % (name, newname)) + self.core.log.debug("Redirected import %s -> %s" % (name, newname)) module = __import__(newname, globals(), locals(), [plugin]) #inject under new an old name @@ -330,7 +327,7 @@ class PluginManager: if not type_plugins: return None - self.log.debug("Request reload of plugins: %s" % type_plugins) + self.core.log.debug("Request reload of plugins: %s" % type_plugins) reloaded = [] @@ -343,18 +340,18 @@ class PluginManager: for type in as_dict.iterkeys(): if type in ("addon", "internal"): #: do not reload them because would cause to much side effects - self.log.debug("Skipping reload for plugin: [%(type)s] %(name)s" % {'name': plugin, 'type': type}) + self.core.log.debug("Skipping reload for plugin: [%(type)s] %(name)s" % {'name': plugin, 'type': type}) continue for plugin in as_dict[type]: if plugin in self.plugins[type] and "module" in self.plugins[type][plugin]: - self.log.debug(_("Reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}) + self.core.log.debug(_("Reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}) try: reload(self.plugins[type][plugin]['module']) except Exception, e: - self.log.error(_("Error when reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}, e) + self.core.log.error(_("Error when reloading plugin: [%(type)s] %(name)s") % {'name': plugin, 'type': type}, e) continue else: diff --git a/pyload/manager/ThreadManager.py b/pyload/manager/ThreadManager.py index d250a1dfc..1e7bf0f92 100644 --- a/pyload/manager/ThreadManager.py +++ b/pyload/manager/ThreadManager.py @@ -40,7 +40,6 @@ class ThreadManager: def __init__(self, core): """Constructor""" self.core = core - self.log = core.log self.threads = [] #: thread list self.localThreads = [] #: addon+decrypter threads @@ -133,7 +132,7 @@ class ThreadManager: try: self.tryReconnect() except Exception, e: - self.log.error(_("Reconnect Failed: %s") % str(e) ) + self.core.log.error(_("Reconnect Failed: %s") % str(e) ) self.reconnecting.clear() if self.core.debug: print_exc() @@ -142,7 +141,7 @@ class ThreadManager: try: self.assignJob() except Exception, e: - self.log.warning("Assign job error", e) + self.core.log.warning("Assign job error", e) if self.core.debug: print_exc() @@ -153,7 +152,7 @@ class ThreadManager: if (self.infoCache or self.infoResults) and self.timestamp < time(): self.infoCache.clear() self.infoResults.clear() - self.log.debug("Cleared Result cache") + self.core.log.debug("Cleared Result cache") #-------------------------------------------------------------------------- def tryReconnect(self): @@ -172,13 +171,13 @@ class ThreadManager: self.core.config['reconnect']['method'] = join(pypath, self.core.config['reconnect']['method']) else: self.core.config["reconnect"]["activated"] = False - self.log.warning(_("Reconnect script not found!")) + self.core.log.warning(_("Reconnect script not found!")) return self.reconnecting.set() #Do reconnect - self.log.info(_("Starting reconnect")) + self.core.log.info(_("Starting reconnect")) while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0: sleep(0.25) @@ -187,12 +186,12 @@ class ThreadManager: self.core.addonManager.beforeReconnecting(ip) - self.log.debug("Old IP: %s" % ip) + self.core.log.debug("Old IP: %s" % ip) try: reconn = Popen(self.core.config['reconnect']['method'], bufsize=-1, shell=True)#, stdout=subprocess.PIPE) except: - self.log.warning(_("Failed executing reconnect script!")) + self.core.log.warning(_("Failed executing reconnect script!")) self.core.config["reconnect"]["activated"] = False self.reconnecting.clear() if self.core.debug: @@ -204,7 +203,7 @@ class ThreadManager: ip = self.getIP() self.core.addonManager.afterReconnecting(ip) - self.log.info(_("Reconnected, new IP: %s") % ip) + self.core.log.info(_("Reconnected, new IP: %s") % ip) self.reconnecting.clear() @@ -247,7 +246,7 @@ class ThreadManager: pycurl.global_cleanup() pycurl.global_init(pycurl.GLOBAL_DEFAULT) self.downloaded = 0 - self.log.debug("Cleaned up pycurl") + self.core.log.debug("Cleaned up pycurl") return True #-------------------------------------------------------------------------- @@ -274,7 +273,7 @@ class ThreadManager: try: job.initPlugin() except Exception, e: - self.log.critical(str(e)) + self.core.log.critical(str(e)) print_exc() job.setStatus("failed") job.error = str(e) @@ -284,7 +283,7 @@ class ThreadManager: if job.plugin.__type__ == "hoster": spaceLeft = freeSpace(self.core.config["general"]["download_folder"]) / 1024 / 1024 if spaceLeft < self.core.config["general"]["min_free_space"]: - self.log.warning(_("Not enough space left on device")) + self.core.log.warning(_("Not enough space left on device")) self.pause = True if free and not self.pause: |