diff options
-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 | ||||
-rw-r--r-- | pyload/plugins/Plugin.py | 31 | ||||
-rw-r--r-- | pyload/plugins/crypter/LinkCryptWs.py | 4 | ||||
-rw-r--r-- | pyload/plugins/crypter/MultiuploadCom.py | 2 | ||||
-rw-r--r-- | pyload/plugins/internal/Addon.py | 4 | ||||
-rw-r--r-- | pyload/plugins/internal/Container.py | 2 | ||||
-rw-r--r-- | pyload/plugins/internal/Crypter.py | 2 | ||||
-rw-r--r-- | pyload/plugins/internal/MultiHoster.py | 2 | ||||
-rw-r--r-- | pyload/plugins/internal/OCR.py | 2 |
12 files changed, 59 insertions, 76 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: diff --git a/pyload/plugins/Plugin.py b/pyload/plugins/Plugin.py index a4b4cf74e..0b8e02512 100644 --- a/pyload/plugins/Plugin.py +++ b/pyload/plugins/Plugin.py @@ -54,15 +54,11 @@ class Base(object): def __init__(self, core): #: Core instance self.core = core - #: logging instance - self.log = core.log - #: core config - self.config = core.config def _log(self, type, args): msg = " | ".join([str(a).strip() for a in args if a]) - logger = getattr(self.log, type) + logger = getattr(self.core.log, type) logger("%s: %s" % (self.__name__, msg or _("%s MARK" % type.upper()))) @@ -228,21 +224,16 @@ class Plugin(Base): #: captcha task self.cTask = None - self.html = None #@TODO: Move to hoster class + self.html = None #@TODO: Move to hoster class in 0.4.10 self.retries = 0 - #: some plugins store html code here - - #: quick caller for API - # self.api = self.core.api - self.init() def getChunkCount(self): if self.chunkLimit <= 0: - return self.config['download']['chunks'] - return min(self.config['download']['chunks'], self.chunkLimit) + return self.core.config['download']['chunks'] + return min(self.core.config['download']['chunks'], self.chunkLimit) def __call__(self): @@ -607,7 +598,7 @@ class Plugin(Base): self.pyfile.setStatus("downloading") - download_folder = self.config['general']['download_folder'] + download_folder = self.core.config['general']['download_folder'] location = safe_join(download_folder, self.pyfile.package().folder) @@ -616,8 +607,8 @@ class Plugin(Base): makedirs(location, int(self.core.config['permission']['folder'], 8)) if self.core.config['permission']['change_dl'] and os.name != "nt": - uid = getpwnam(self.config['permission']['user'])[2] - gid = getgrnam(self.config['permission']['group'])[2] + uid = getpwnam(self.core.config['permission']['user'])[2] + gid = getgrnam(self.core.config['permission']['group'])[2] chown(location, uid, gid) except Exception, e: @@ -656,8 +647,8 @@ class Plugin(Base): if self.core.config['permission']['change_dl'] and os.name != "nt": try: - uid = getpwnam(self.config['permission']['user'])[2] - gid = getgrnam(self.config['permission']['group'])[2] + uid = getpwnam(self.core.config['permission']['user'])[2] + gid = getgrnam(self.core.config['permission']['group'])[2] chown(fs_filename, uid, gid) except Exception, e: @@ -732,10 +723,10 @@ class Plugin(Base): 5, 7) and starting: #a download is waiting/starting and was appenrently started before raise SkipDownload(pyfile.pluginname) - download_folder = self.config['general']['download_folder'] + download_folder = self.core.config['general']['download_folder'] location = safe_join(download_folder, pack.folder, self.pyfile.name) - if starting and self.config['download']['skip_existing'] and exists(location): + if starting and self.core.config['download']['skip_existing'] and exists(location): size = os.stat(location).st_size if size >= self.pyfile.size: raise SkipDownload("File exists") diff --git a/pyload/plugins/crypter/LinkCryptWs.py b/pyload/plugins/crypter/LinkCryptWs.py index bbcef02fd..4eb48deae 100644 --- a/pyload/plugins/crypter/LinkCryptWs.py +++ b/pyload/plugins/crypter/LinkCryptWs.py @@ -188,10 +188,10 @@ class LinkCryptWs(Crypter): def handleLinkSource(self, type_): - if type_ is 'cnl': + if type_ == 'cnl': return self.handleCNL2() - elif type_ is 'web': + elif type_ == 'web': return self.handleWebLinks() elif type_ in ('rsdf', 'ccf', 'dlc'): diff --git a/pyload/plugins/crypter/MultiuploadCom.py b/pyload/plugins/crypter/MultiuploadCom.py index 61295bc85..713d67c18 100644 --- a/pyload/plugins/crypter/MultiuploadCom.py +++ b/pyload/plugins/crypter/MultiuploadCom.py @@ -10,6 +10,6 @@ class MultiuploadCom(DeadCrypter): __pattern__ = r'http://(?:www\.)?multiupload\.(com|nl)/\w+' - __description__ = """ MultiUpload.com decrypter plugin """ + __description__ = """MultiUpload.com decrypter plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] diff --git a/pyload/plugins/internal/Addon.py b/pyload/plugins/internal/Addon.py index 1aa51c69a..e0be3097e 100644 --- a/pyload/plugins/internal/Addon.py +++ b/pyload/plugins/internal/Addon.py @@ -30,7 +30,7 @@ class Addon(Base): __config__ = [] #: [("name", "type", "desc", "default")] - __description__ = """Interface for addon""" + __description__ = """Base addon/hook plugin""" __license__ = "GPLv3" __authors__ = [("mkaay", "mkaay@mkaay.de"), ("RaNaN", "RaNaN@pyload.org")] @@ -113,7 +113,7 @@ class Addon(Base): def isActivated(self): """ checks if addon is activated""" - return self.config.getPlugin(self.__name__, "activated") + return self.core.config.getPlugin(self.__name__, "activated") #event methods - overwrite these if needed diff --git a/pyload/plugins/internal/Container.py b/pyload/plugins/internal/Container.py index 4bd6644f9..b7dd3aa20 100644 --- a/pyload/plugins/internal/Container.py +++ b/pyload/plugins/internal/Container.py @@ -43,7 +43,7 @@ class Container(Crypter): if self.pyfile.url.startswith("http"): self.pyfile.name = re.findall("([^\/=]+)", self.pyfile.url)[-1] content = self.load(self.pyfile.url) - self.pyfile.url = safe_join(self.config['general']['download_folder'], self.pyfile.name) + self.pyfile.url = safe_join(self.core.config['general']['download_folder'], self.pyfile.name) try: with open(self.pyfile.url, "wb") as f: f.write(content) diff --git a/pyload/plugins/internal/Crypter.py b/pyload/plugins/internal/Crypter.py index ed92357a5..4fae07ff1 100644 --- a/pyload/plugins/internal/Crypter.py +++ b/pyload/plugins/internal/Crypter.py @@ -63,7 +63,7 @@ class Crypter(Plugin): package_password = self.pyfile.package().password package_queue = self.pyfile.package().queue - folder_per_package = self.config['general']['folder_per_package'] + folder_per_package = self.core.config['general']['folder_per_package'] try: use_subfolder = self.getConfig('use_subfolder') except: diff --git a/pyload/plugins/internal/MultiHoster.py b/pyload/plugins/internal/MultiHoster.py index 88a9c888b..02594e04e 100644 --- a/pyload/plugins/internal/MultiHoster.py +++ b/pyload/plugins/internal/MultiHoster.py @@ -11,7 +11,7 @@ class MultiHoster(Addon): __type__ = "addon" __version__ = "0.20" - __description__ = """Generic MultiHoster plugin""" + __description__ = """Base multi-hoster plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] diff --git a/pyload/plugins/internal/OCR.py b/pyload/plugins/internal/OCR.py index b5ee30cb7..dec9f28b7 100644 --- a/pyload/plugins/internal/OCR.py +++ b/pyload/plugins/internal/OCR.py @@ -18,7 +18,7 @@ class OCR(object): __type__ = "ocr" __version__ = "0.01" - __description__ = """OCR base plugin""" + __description__ = """Base OCR plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] |