diff options
Diffstat (limited to 'pyload/manager')
-rw-r--r-- | pyload/manager/AccountManager.py | 6 | ||||
-rw-r--r-- | pyload/manager/AddonManager.py | 37 | ||||
-rw-r--r-- | pyload/manager/CaptchaManager.py | 26 | ||||
-rw-r--r-- | pyload/manager/PluginManager.py | 8 | ||||
-rw-r--r-- | pyload/manager/RemoteManager.py | 2 | ||||
-rw-r--r-- | pyload/manager/ThreadManager.py | 6 | ||||
-rw-r--r-- | pyload/manager/event/PullEvents.py | 16 | ||||
-rw-r--r-- | pyload/manager/event/Scheduler.py | 8 | ||||
-rw-r--r-- | pyload/manager/thread/DownloadThread.py | 2 | ||||
-rw-r--r-- | pyload/manager/thread/InfoThread.py | 6 | ||||
-rw-r--r-- | pyload/manager/thread/PluginThread.py | 2 | ||||
-rw-r--r-- | pyload/manager/thread/ServerThread.py | 2 |
12 files changed, 53 insertions, 68 deletions
diff --git a/pyload/manager/AccountManager.py b/pyload/manager/AccountManager.py index 4e9e36cee..9dc98770c 100644 --- a/pyload/manager/AccountManager.py +++ b/pyload/manager/AccountManager.py @@ -11,7 +11,7 @@ from pyload.utils import chmod, lock ACC_VERSION = 1 -class AccountManager: +class AccountManager(object): """manages all accounts""" #---------------------------------------------------------------------- @@ -47,7 +47,7 @@ class AccountManager: return self.plugins[plugin] else: raise - except: + except Exception: return None @@ -100,7 +100,7 @@ class AccountManager: try: option = line[1:].split() self.accounts[plugin][name]['options'][option[0]] = [] if len(option) < 2 else ([option[1]] if len(option) < 3 else option[1:]) - except: + except Exception: pass elif ":" in line: diff --git a/pyload/manager/AddonManager.py b/pyload/manager/AddonManager.py index a394373a9..d4b43cb93 100644 --- a/pyload/manager/AddonManager.py +++ b/pyload/manager/AddonManager.py @@ -28,7 +28,8 @@ from pyload.manager.thread.AddonThread import AddonThread from pyload.manager.PluginManager import literal_eval from utils import lock -class AddonManager: + +class AddonManager(object): """Manages addons, delegates and handles Events. Every plugin can define events, \ @@ -69,7 +70,7 @@ class AddonManager: self.events = {} # contains events - #registering callback for config event + # registering callback for config event self.core.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) self.addEvent("pluginConfigChanged", self.manageAddon) @@ -85,10 +86,8 @@ class AddonManager: args[0].log.error(_("Error executing addon: %s") % e) if args[0].core.debug: traceback.print_exc() - return new - def addRPC(self, plugin, func, doc): plugin = plugin.rpartition(".")[2] doc = doc.strip() if doc else "" @@ -102,22 +101,18 @@ class AddonManager: if not args: args = tuple() if parse: args = tuple([literal_eval(x) for x in args]) - plugin = self.pluginMap[plugin] f = getattr(plugin, func) return f(*args) - def createIndex(self): plugins = [] - active = [] deactive = [] for pluginname in self.core.pluginManager.addonPlugins: try: # hookClass = getattr(plugin, plugin.__name__) - if self.core.config.getPlugin(pluginname, "activated"): pluginClass = self.core.pluginManager.loadClass("addon", pluginname) if not pluginClass: continue @@ -130,8 +125,7 @@ class AddonManager: else: deactive.append(pluginname) - - except: + except Exception: self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) if self.core.debug: traceback.print_exc() @@ -148,14 +142,15 @@ class AddonManager: self.deactivateAddon(plugin) def activateAddon(self, plugin): - #check if already loaded + # check if already loaded for inst in self.plugins: if inst.__name__ == plugin: return pluginClass = self.core.pluginManager.loadClass("addon", plugin) - if not pluginClass: return + if not pluginClass: + return self.core.log.debug("Plugin loaded: %s" % plugin) @@ -193,7 +188,6 @@ class AddonManager: for plugin in self.plugins: if plugin.isActivated(): plugin.coreReady() - self.dispatchEvent("coreReady") @try_catch @@ -201,7 +195,6 @@ class AddonManager: for plugin in self.plugins: if plugin.isActivated(): plugin.coreExiting() - self.dispatchEvent("coreExiting") @lock @@ -209,7 +202,6 @@ class AddonManager: for plugin in self.plugins: if plugin.isActivated(): plugin.downloadPreparing(pyfile) - self.dispatchEvent("downloadPreparing", pyfile) @lock @@ -241,7 +233,6 @@ class AddonManager: def beforeReconnecting(self, ip): for plugin in self.plugins: plugin.beforeReconnecting(ip) - self.dispatchEvent("beforeReconnecting", ip) @lock @@ -249,7 +240,6 @@ class AddonManager: for plugin in self.plugins: if plugin.isActivated(): plugin.afterReconnecting(ip) - self.dispatchEvent("afterReconnecting", ip) def startThread(self, function, *args, **kwargs): @@ -264,17 +254,16 @@ class AddonManager: info = {} for name, plugin in self.pluginMap.iteritems(): if plugin.info: - #copy and convert so str - info[name] = dict([(x, str(y) if not isinstance(y, basestring) else y) for x, y in plugin.info.iteritems()]) + # copy and convert so str + info[name] = dict( + [(x, str(y) if not isinstance(y, basestring) else y) for x, y in plugin.info.iteritems()]) return info - def getInfo(self, plugin): info = {} if plugin in self.pluginMap and self.pluginMap[plugin].info: - info = dict([(x, str(y) if not isinstance(y, basestring) else y) - for x, y in self.pluginMap[plugin].info.iteritems()]) - + info = dict((x, str(y) if not isinstance(y, basestring) else y) + for x, y in self.pluginMap[plugin].info.iteritems()) return info def addEvent(self, event, func): @@ -297,6 +286,6 @@ class AddonManager: f(*args) except Exception, e: self.core.log.warning("Error calling event handler %s: %s, %s, %s" - % (event, f, args, str(e))) + % (event, f, args, str(e))) if self.core.debug: traceback.print_exc() diff --git a/pyload/manager/CaptchaManager.py b/pyload/manager/CaptchaManager.py index b89fb3136..955d35b43 100644 --- a/pyload/manager/CaptchaManager.py +++ b/pyload/manager/CaptchaManager.py @@ -24,13 +24,12 @@ from threading import Lock from pyload.utils import encode -class CaptchaManager: +class CaptchaManager(object): def __init__(self, core): self.lock = Lock() self.core = core - self.tasks = [] #task store, for outgoing tasks only - - self.ids = 0 #only for internal purpose + self.tasks = [] # task store, for outgoing tasks only + self.ids = 0 # only for internal purpose def newTask(self, img, format, file, result_type): task = CaptchaTask(self.ids, img, format, file, result_type) @@ -55,7 +54,7 @@ class CaptchaManager: def getTaskByID(self, tid): self.lock.acquire() for task in self.tasks: - if task.id == str(tid): #task ids are strings + if task.id == str(tid): # task ids are strings self.lock.release() return task self.lock.release() @@ -64,26 +63,24 @@ class CaptchaManager: def handleCaptcha(self, task, timeout=50): cli = self.core.isClientConnected() - if cli: #client connected -> should solve the captcha + if cli: #: client connected -> should solve the captcha task.setWaiting(timeout) #wait 50 sec for response for plugin in self.core.addonManager.activePlugins(): try: plugin.newCaptchaTask(task) - except: + except Exception: if self.core.debug: print_exc() - if task.handler or cli: #the captcha was handled + if task.handler or cli: #: the captcha was handled self.tasks.append(task) return True - task.error = _("No Client connected for captcha decrypting") - return False -class CaptchaTask: +class CaptchaTask(object): def __init__(self, id, img, format, file, result_type='textual'): self.id = str(id) self.captchaImg = img @@ -93,10 +90,9 @@ class CaptchaTask: self.handler = [] #: the hook plugins that will take care of the solution self.result = None self.waitUntil = None - self.error = None #error message - + self.error = None # error message self.status = "init" - self.data = {} #handler can store data here + self.data = {} # handler can store data here def getCaptcha(self): return self.captchaImg, self.captchaFormat, self.captchaResultType @@ -108,7 +104,7 @@ class CaptchaTask: try: parts = text.split(',') self.result = (int(parts[0]), int(parts[1])) - except: + except Exception: self.result = None def getResult(self): diff --git a/pyload/manager/PluginManager.py b/pyload/manager/PluginManager.py index 79c3d6be6..b071ac476 100644 --- a/pyload/manager/PluginManager.py +++ b/pyload/manager/PluginManager.py @@ -12,7 +12,7 @@ from traceback import print_exc from SafeEval import const_eval as literal_eval -class PluginManager: +class PluginManager(object): ROOT = "pyload.plugins." USERROOT = "userplugins." TYPES = [] @@ -141,7 +141,7 @@ class PluginManager: try: regexp = re.compile(pattern) - except: + except Exception: self.core.log.error(_("%s has a invalid pattern") % name) pattern = r'^unmatchable$' regexp = re.compile(pattern) @@ -170,7 +170,7 @@ class PluginManager: config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True]) self.core.config.addPluginConfig(name, config, desc) - except: + except Exception: self.core.log.error("Invalid config in %s: %s" % (name, config)) elif folder in ("addon", "hook"): #force config creation @@ -180,7 +180,7 @@ class PluginManager: try: self.core.config.addPluginConfig(name, config, desc) - except: + except Exception: self.core.log.error("Invalid config in %s: %s" % (name, config)) if not rootplugins and plugins: #: Double check diff --git a/pyload/manager/RemoteManager.py b/pyload/manager/RemoteManager.py index e53e317e3..1ce007c6c 100644 --- a/pyload/manager/RemoteManager.py +++ b/pyload/manager/RemoteManager.py @@ -55,7 +55,7 @@ class BackendBase(Thread): self.shutdown() -class RemoteManager: +class RemoteManager(object): available = [] def __init__(self, core): diff --git a/pyload/manager/ThreadManager.py b/pyload/manager/ThreadManager.py index 1e7bf0f92..c1204c632 100644 --- a/pyload/manager/ThreadManager.py +++ b/pyload/manager/ThreadManager.py @@ -33,7 +33,7 @@ from pyload.network.RequestFactory import getURL from pyload.utils import freeSpace, lock -class ThreadManager: +class ThreadManager(object): """manages the download threads, assign jobs, reconnect etc""" @@ -190,7 +190,7 @@ class ThreadManager: try: reconn = Popen(self.core.config['reconnect']['method'], bufsize=-1, shell=True)#, stdout=subprocess.PIPE) - except: + except Exception: self.core.log.warning(_("Failed executing reconnect script!")) self.core.config["reconnect"]["activated"] = False self.reconnecting.clear() @@ -219,7 +219,7 @@ class ThreadManager: ip = getURL(sv[0]) ip = re.match(sv[1], ip).group(1) break - except: + except Exception: ip = "" sleep(1) diff --git a/pyload/manager/event/PullEvents.py b/pyload/manager/event/PullEvents.py index 0739b4ec8..aa78f590e 100644 --- a/pyload/manager/event/PullEvents.py +++ b/pyload/manager/event/PullEvents.py @@ -20,7 +20,7 @@ from time import time from pyload.utils import uniqify -class PullManager: +class PullManager(object): def __init__(self, core): self.core = core self.clients = [] @@ -52,7 +52,7 @@ class PullManager: for client in self.clients: client.addEvent(event) -class Client: +class Client(object): def __init__(self, uuid): self.uuid = uuid self.lastActive = time() @@ -69,7 +69,7 @@ class Client: def addEvent(self, event): self.events.append(event) -class UpdateEvent: +class UpdateEvent(object): def __init__(self, itype, iid, destination): assert itype == "pack" or itype == "file" assert destination == "queue" or destination == "collector" @@ -80,7 +80,7 @@ class UpdateEvent: def toList(self): return ["update", self.destination, self.type, self.id] -class RemoveEvent: +class RemoveEvent(object): def __init__(self, itype, iid, destination): assert itype == "pack" or itype == "file" assert destination == "queue" or destination == "collector" @@ -91,7 +91,7 @@ class RemoveEvent: def toList(self): return ["remove", self.destination, self.type, self.id] -class InsertEvent: +class InsertEvent(object): def __init__(self, itype, iid, after, destination): assert itype == "pack" or itype == "file" assert destination == "queue" or destination == "collector" @@ -103,7 +103,7 @@ class InsertEvent: def toList(self): return ["insert", self.destination, self.type, self.id, self.after] -class ReloadAllEvent: +class ReloadAllEvent(object): def __init__(self, destination): assert destination == "queue" or destination == "collector" self.destination = destination @@ -111,10 +111,10 @@ class ReloadAllEvent: def toList(self): return ["reload", self.destination] -class AccountUpdateEvent: +class AccountUpdateEvent(object): def toList(self): return ["account"] -class ConfigUpdateEvent: +class ConfigUpdateEvent(object): def toList(self): return ["config"] diff --git a/pyload/manager/event/Scheduler.py b/pyload/manager/event/Scheduler.py index 39dfbc3cc..59b84cfcf 100644 --- a/pyload/manager/event/Scheduler.py +++ b/pyload/manager/event/Scheduler.py @@ -25,7 +25,7 @@ class AlreadyCalled(Exception): pass -class Deferred: +class Deferred(object): def __init__(self): self.call = [] self.result = () @@ -43,7 +43,7 @@ class Deferred: f(*args ** kwargs) -class Scheduler: +class Scheduler(object): def __init__(self, core): self.core = core @@ -87,7 +87,7 @@ class Scheduler: break -class Job: +class Job(object): def __init__(self, time, call, args=[], kwargs={}, deferred=None, threaded=True): self.time = float(time) self.call = call @@ -112,7 +112,7 @@ class Job: self.run() -class PriorityQueue: +class PriorityQueue(object): """ a non blocking priority queue """ def __init__(self): diff --git a/pyload/manager/thread/DownloadThread.py b/pyload/manager/thread/DownloadThread.py index 86e18973e..5ecdd9953 100644 --- a/pyload/manager/thread/DownloadThread.py +++ b/pyload/manager/thread/DownloadThread.py @@ -93,7 +93,7 @@ class DownloadThread(PluginThread): except Abort: try: self.m.log.info(_("Download aborted: %s") % pyfile.name) - except: + except Exception: pass pyfile.setStatus("aborted") diff --git a/pyload/manager/thread/InfoThread.py b/pyload/manager/thread/InfoThread.py index 4edc55545..807910cd2 100644 --- a/pyload/manager/thread/InfoThread.py +++ b/pyload/manager/thread/InfoThread.py @@ -64,7 +64,7 @@ class InfoThread(PluginThread): for url, plugintype, pluginname in data: try: plugins[plugintype][pluginname].append(url) - except: + except Exception: plugins[plugintype][pluginname] = [url] # filter out container plugins @@ -111,7 +111,7 @@ class InfoThread(PluginThread): #attach container content try: data = self.decryptContainer(name, url) - except: + except Exception: print_exc() self.m.log.error("Could not decrypt container.") data = [] @@ -119,7 +119,7 @@ class InfoThread(PluginThread): for url, plugintype, pluginname in data: try: plugins[plugintype][pluginname].append(url) - except: + except Exception: plugins[plugintype][pluginname] = [url] self.m.infoResults[self.rid] = {} diff --git a/pyload/manager/thread/PluginThread.py b/pyload/manager/thread/PluginThread.py index faa1bba59..f3a49d621 100644 --- a/pyload/manager/thread/PluginThread.py +++ b/pyload/manager/thread/PluginThread.py @@ -64,7 +64,7 @@ class PluginThread(Thread): try: # avoid encoding errors zip.write(join("tmp", pyfile.pluginname, f), safe_join(pyfile.pluginname, f)) - except: + except Exception: pass info = zipfile.ZipInfo(safe_join(pyfile.pluginname, "debug_Report.txt"), gmtime()) diff --git a/pyload/manager/thread/ServerThread.py b/pyload/manager/thread/ServerThread.py index 7de3b1ca1..0f3ed01ff 100644 --- a/pyload/manager/thread/ServerThread.py +++ b/pyload/manager/thread/ServerThread.py @@ -44,7 +44,7 @@ class WebServer(threading.Thread): elif self.server == "fastcgi": try: import flup - except: + except Exception: log.warning(_("Can't use %(server)s, python-flup is not installed!") % { "server": self.server}) reset = True |