diff options
Diffstat (limited to 'pyload/manager')
-rw-r--r-- | pyload/manager/Account.py | 8 | ||||
-rw-r--r-- | pyload/manager/Addon.py | 4 | ||||
-rw-r--r-- | pyload/manager/Captcha.py | 10 | ||||
-rw-r--r-- | pyload/manager/Plugin.py | 14 | ||||
-rw-r--r-- | pyload/manager/Thread.py | 6 | ||||
-rw-r--r-- | pyload/manager/thread/Addon.py | 2 | ||||
-rw-r--r-- | pyload/manager/thread/Download.py | 2 | ||||
-rw-r--r-- | pyload/manager/thread/Info.py | 14 | ||||
-rw-r--r-- | pyload/manager/thread/Plugin.py | 9 | ||||
-rw-r--r-- | pyload/manager/thread/Server.py | 9 |
10 files changed, 41 insertions, 37 deletions
diff --git a/pyload/manager/Account.py b/pyload/manager/Account.py index 44a5e5c65..ac9944134 100644 --- a/pyload/manager/Account.py +++ b/pyload/manager/Account.py @@ -126,8 +126,8 @@ class AccountManager(object): f.write("\n") f.write(plugin + ":\n") - for name,data in accounts.iteritems(): - f.write("\n\t%s:%s\n" % (name,data['password']) ) + for name, data in accounts.iteritems(): + f.write("\n\t%s:%s\n" % (name, data['password']) ) if data['options']: for option, values in data['options'].iteritems(): f.write("\t@%s %s\n" % (option, " ".join(values))) @@ -147,12 +147,12 @@ class AccountManager(object): @lock - def updateAccount(self, plugin , user, password=None, options={}): + def updateAccount(self, plugin, user, password=None, options={}): """add or update account""" if plugin in self.accounts: p = self.getAccountPlugin(plugin) updated = p.updateAccounts(user, password, options) - #since accounts is a ref in plugin self.accounts doesnt need to be updated here + # since accounts is a ref in plugin self.accounts doesnt need to be updated here self.saveAccounts() if updated: p.scheduleRefresh(user, force=False) diff --git a/pyload/manager/Addon.py b/pyload/manager/Addon.py index 5ac56a349..2a3bc4318 100644 --- a/pyload/manager/Addon.py +++ b/pyload/manager/Addon.py @@ -89,7 +89,7 @@ class AddonManager(object): def callRPC(self, plugin, func, args, parse): if not args: - args = tuple() + args = () if parse: args = tuple([literal_eval(x) for x in args]) plugin = self.pluginMap[plugin] @@ -169,7 +169,7 @@ class AddonManager(object): addon.deactivate() - #remove periodic call + # remove periodic call self.core.log.debug("Removed callback: %s" % self.core.scheduler.removeJob(addon.cb)) self.plugins.remove(addon) diff --git a/pyload/manager/Captcha.py b/pyload/manager/Captcha.py index 4a7582d65..ab9f79b37 100644 --- a/pyload/manager/Captcha.py +++ b/pyload/manager/Captcha.py @@ -13,8 +13,8 @@ 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): @@ -43,7 +43,7 @@ class CaptchaManager(object): 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() @@ -81,9 +81,9 @@ class CaptchaTask(object): 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): diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py index bcaf06bde..c6ba5e81b 100644 --- a/pyload/manager/Plugin.py +++ b/pyload/manager/Plugin.py @@ -129,7 +129,7 @@ class PluginManager(object): module = f.replace(".pyc", "").replace(".py", "") # the plugin is loaded from user directory - plugins[name]['user'] = True if rootplugins else False + plugins[name]['user'] = bool(rootplugins) plugins[name]['name'] = module pattern = self.PATTERN.findall(content) @@ -165,13 +165,13 @@ class PluginManager(object): config = [list(config)] 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]) + config.insert(0, ["activated", "bool", "Activated", not folder in ("addon", "hook")]) self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc) except Exception: self.core.log.error("Invalid config in %s: %s" % (name, config)) - elif folder in ("addon", "hook"): # force config creation + elif folder in ("addon", "hook"): #: force config creation desc = self.DESC.findall(content) desc = desc[0][1] if desc else "" config = (["activated", "bool", "Activated", False],) @@ -313,9 +313,9 @@ class PluginManager(object): def find_module(self, fullname, path=None): # redirecting imports if necesarry - if fullname.startswith(self.ROOT) or fullname.startswith(self.USERROOT): # seperate pyload plugins + if fullname.startswith(self.ROOT) or fullname.startswith(self.USERROOT): #: seperate pyload plugins if fullname.startswith(self.USERROOT): user = 1 - else: user = 0 # used as bool and int + else: user = 0 #: used as bool and int split = fullname.split(".") if len(split) != 4 - user: @@ -332,7 +332,7 @@ class PluginManager(object): def load_module(self, name, replace=True): - if name not in sys.modules: # could be already in modules + if name not in sys.modules: #: could be already in modules if replace: if self.ROOT in name: newname = name.replace(self.ROOT, self.USERROOT) @@ -401,4 +401,4 @@ class PluginManager(object): def reloadPlugin(self, type_plugin): """ reload and reindex ONE plugin """ - return True if self.reloadPlugins(type_plugin) else False + return bool(self.reloadPlugins(type_plugin)) diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py index a8550e504..a2a64c38d 100644 --- a/pyload/manager/Thread.py +++ b/pyload/manager/Thread.py @@ -33,7 +33,7 @@ class ThreadManager(object): self.reconnecting = Event() self.reconnecting.clear() - self.downloaded = 0 # number of files downloaded since last cleanup + self.downloaded = 0 #: number of files downloaded since last cleanup self.lock = Lock() @@ -51,7 +51,7 @@ class ThreadManager(object): pycurl.global_init(pycurl.GLOBAL_DEFAULT) - for _i in range(0, self.core.config.get("download", "max_downloads")): + for _i in xrange(0, self.core.config.get("download", "max_downloads")): self.createThread() @@ -206,7 +206,7 @@ class ThreadManager(object): ("http://checkip.dyndns.org/", ".*Current IP Address: (\S+)</body>.*")] ip = "" - for _i in range(10): + for _i in xrange(10): try: sv = choice(services) ip = getURL(sv[0]) diff --git a/pyload/manager/thread/Addon.py b/pyload/manager/thread/Addon.py index 1da164543..b176e4e0c 100644 --- a/pyload/manager/thread/Addon.py +++ b/pyload/manager/thread/Addon.py @@ -58,7 +58,7 @@ class AddonThread(PluginThread): self.kwargs['thread'] = self self.f(*self.args, **self.kwargs) except TypeError, e: - #dirty method to filter out exceptions + # dirty method to filter out exceptions if "unexpected keyword argument 'thread'" not in e.args[0]: raise diff --git a/pyload/manager/thread/Download.py b/pyload/manager/thread/Download.py index 21db61ca4..293014a2e 100644 --- a/pyload/manager/thread/Download.py +++ b/pyload/manager/thread/Download.py @@ -39,7 +39,7 @@ class DownloadThread(PluginThread): while True: del pyfile - self.active = False # sets the thread inactive when it is ready to get next job + self.active = False #: sets the thread inactive when it is ready to get next job self.active = self.queue.get() pyfile = self.active diff --git a/pyload/manager/thread/Info.py b/pyload/manager/thread/Info.py index 28a2e8e91..9d8a3ef5b 100644 --- a/pyload/manager/thread/Info.py +++ b/pyload/manager/thread/Info.py @@ -26,13 +26,13 @@ class InfoThread(PluginThread): PluginThread.__init__(self, manager) self.data = data - self.pid = pid # package id + self.pid = pid #: package id # [ .. (name, plugin) .. ] - self.rid = rid # result id - self.add = add # add packages instead of return result + self.rid = rid #: result id + self.add = add #: add packages instead of return result - self.cache = [] # accumulated data + self.cache = [] #: accumulated data self.start() @@ -83,7 +83,7 @@ class InfoThread(PluginThread): # empty cache del self.cache[:] - else: # post the results + else: #: post the results for name, url in container: # attach container content @@ -154,8 +154,8 @@ class InfoThread(PluginThread): def fetchForPlugin(self, pluginname, plugin, urls, cb, err=None): try: - result = [] # result loaded from cache - process = [] # urls to process + result = [] #: result loaded from cache + process = [] #: urls to process for url in urls: if url in self.m.infoCache: result.append(self.m.infoCache[url]) diff --git a/pyload/manager/thread/Plugin.py b/pyload/manager/thread/Plugin.py index 08a2664da..d8319a2ce 100644 --- a/pyload/manager/thread/Plugin.py +++ b/pyload/manager/thread/Plugin.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # @author: RaNaN +from __future__ import with_statement + from Queue import Queue from threading import Thread from os import listdir, stat @@ -64,9 +66,8 @@ class PluginThread(Thread): self.m.log.debug("Error creating zip file: %s" % e) dump_name = dump_name.replace(".zip", ".txt") - f = open(dump_name, "wb") - f.write(dump) - f.close() + with open(dump_name, "wb") as f: + f.write(dump) self.m.core.log.info("Debug Report written to %s" % dump_name) @@ -128,5 +129,5 @@ class PluginThread(Thread): def clean(self, pyfile): """ set thread unactive and release pyfile """ - self.active = True #release pyfile but lets the thread active + self.active = True #: release pyfile but lets the thread active pyfile.release() diff --git a/pyload/manager/thread/Server.py b/pyload/manager/thread/Server.py index 83e886253..97590013e 100644 --- a/pyload/manager/thread/Server.py +++ b/pyload/manager/thread/Server.py @@ -89,11 +89,13 @@ class WebServer(threading.Thread): def start_threaded(self): if self.https: - self.core.log.info(_("Starting threaded SSL webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + self.core.log.info( + _("Starting threaded SSL webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) else: self.cert = "" self.key = "" - self.core.log.info(_("Starting threaded webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + self.core.log.info( + _("Starting threaded webserver: %(host)s:%(port)d") % {"host": self.host, "port": self.port}) webinterface.run_threaded(host=self.host, port=self.port, cert=self.cert, key=self.key) @@ -111,7 +113,8 @@ class WebServer(threading.Thread): if self.https: log.warning(_("This server offers no SSL, please consider using threaded instead")) - self.core.log.info(_("Starting lightweight webserver (bjoern): %(host)s:%(port)d") % {"host": self.host, "port": self.port}) + self.core.log.info( + _("Starting lightweight webserver (bjoern): %(host)s:%(port)d") % {"host": self.host, "port": self.port}) webinterface.run_lightweight(host=self.host, port=self.port) |