From 3e87db92c439a4b8378a165f42a01ba142b56a5c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 00:50:31 +0200 Subject: Spare code cosmetics (1) --- pyload/manager/Thread.py | 6 +++--- pyload/manager/thread/Server.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pyload/manager') diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py index 015bc9ab1..e24b20d59 100644 --- a/pyload/manager/Thread.py +++ b/pyload/manager/Thread.py @@ -160,9 +160,9 @@ class ThreadManager(object): if not exists(self.core.config.get("reconnect", "method")): if exists(join(pypath, self.core.config.get("reconnect", "method"))): - self.core.config['reconnect']['method'] = join(pypath, self.core.config.get("reconnect", "method")) + self.core.config.set("reconnect", "method", join(pypath, self.core.config.get("reconnect", "method"))) else: - self.core.config['reconnect']['activated'] = False + self.core.config.set("reconnect", "activated", False) self.core.log.warning(_("Reconnect script not found!")) return @@ -184,7 +184,7 @@ class ThreadManager(object): reconn = Popen(self.core.config.get("reconnect", "method"), bufsize=-1, shell=True) # , stdout=subprocess.PIPE) except Exception: self.core.log.warning(_("Failed executing reconnect script!")) - self.core.config['reconnect']['activated'] = False + self.core.config.set("reconnect", "activated", False) self.reconnecting.clear() if self.core.debug: print_exc() diff --git a/pyload/manager/thread/Server.py b/pyload/manager/thread/Server.py index 990325f5d..83e886253 100644 --- a/pyload/manager/thread/Server.py +++ b/pyload/manager/thread/Server.py @@ -66,7 +66,7 @@ class WebServer(threading.Thread): self.server = "builtin" else: self.core.log.info(_("Server set to threaded, due to known performance problems on windows.")) - self.core.config['webui']['server'] = "threaded" + self.core.config.set("webui", "server", "threaded") self.server = "threaded" if self.server == "threaded": -- cgit v1.2.3 From 730b160e28d711fad96e6a61070e374ad0966566 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 01:07:33 +0200 Subject: Spare code cosmetics (2) --- pyload/manager/Remote.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pyload/manager') diff --git a/pyload/manager/Remote.py b/pyload/manager/Remote.py index a27667070..b18035a00 100644 --- a/pyload/manager/Remote.py +++ b/pyload/manager/Remote.py @@ -4,6 +4,7 @@ from threading import Thread from traceback import print_exc + class BackendBase(Thread): def __init__(self, manager): @@ -43,7 +44,7 @@ class BackendBase(Thread): def stop(self): - self.enabled = False# set flag and call shutdowm message, so thread can react + self.enabled = False #: set flag and call shutdowm message, so thread can react self.shutdown() @@ -57,9 +58,8 @@ class RemoteManager(object): if self.core.remote: self.available.append("ThriftBackend") -# else: -# self.available.append("SocketBackend") - + # else: + # self.available.append("SocketBackend") def startBackends(self): host = self.core.config.get("remote", "listenaddr") -- cgit v1.2.3 From 20226f8cc5889efbefa61209e1adf6184d42cd00 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 01:21:41 +0200 Subject: Spare code cosmetics (3) --- pyload/manager/Plugin.py | 2 +- pyload/manager/thread/Addon.py | 4 ++-- pyload/manager/thread/Info.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'pyload/manager') diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py index 69a77fdf8..e99b1cea6 100644 --- a/pyload/manager/Plugin.py +++ b/pyload/manager/Plugin.py @@ -230,7 +230,7 @@ class PluginManager(object): elif name not in self.plugins[type]: self.core.log.warning(_("Plugin [%(type)s] %(name)s not found | Using plugin: [internal] BasePlugin") % {'name': name, 'type': type}) - return self.internalPlugins["BasePlugin"] + return self.internalPlugins['BasePlugin'] else: return self.plugins[type][name] diff --git a/pyload/manager/thread/Addon.py b/pyload/manager/thread/Addon.py index f3d219989..1da164543 100644 --- a/pyload/manager/thread/Addon.py +++ b/pyload/manager/thread/Addon.py @@ -55,14 +55,14 @@ class AddonThread(PluginThread): def run(self): try: try: - self.kwargs["thread"] = self + self.kwargs['thread'] = self self.f(*self.args, **self.kwargs) except TypeError, e: #dirty method to filter out exceptions if "unexpected keyword argument 'thread'" not in e.args[0]: raise - del self.kwargs["thread"] + del self.kwargs['thread'] self.f(*self.args, **self.kwargs) finally: local = copy(self.active) diff --git a/pyload/manager/thread/Info.py b/pyload/manager/thread/Info.py index 487c3b924..28a2e8e91 100644 --- a/pyload/manager/thread/Info.py +++ b/pyload/manager/thread/Info.py @@ -117,7 +117,7 @@ class InfoThread(PluginThread): self.updateResult(pluginname, result, True) - self.m.infoResults[self.rid]["ALL_INFO_FETCHED"] = {} + self.m.infoResults[self.rid]['ALL_INFO_FETCHED'] = {} self.m.timestamp = time() + 5 * 60 -- cgit v1.2.3 From 938b7e6141e2895c7d41b0e8ef4b9416912e2e9e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 17:28:58 +0200 Subject: Spare code cosmetics (4) --- pyload/manager/Event.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pyload/manager') diff --git a/pyload/manager/Event.py b/pyload/manager/Event.py index 90aaaca30..b3d22619f 100644 --- a/pyload/manager/Event.py +++ b/pyload/manager/Event.py @@ -4,6 +4,7 @@ from time import time from pyload.utils import uniqify + class PullManager(object): def __init__(self, core): @@ -41,6 +42,7 @@ class PullManager(object): for client in self.clients: client.addEvent(event) + class Client(object): def __init__(self, uuid): @@ -62,6 +64,7 @@ class Client(object): def addEvent(self, event): self.events.append(event) + class UpdateEvent(object): def __init__(self, itype, iid, destination): @@ -75,6 +78,7 @@ class UpdateEvent(object): def toList(self): return ["update", self.destination, self.type, self.id] + class RemoveEvent(object): def __init__(self, itype, iid, destination): @@ -88,6 +92,7 @@ class RemoveEvent(object): def toList(self): return ["remove", self.destination, self.type, self.id] + class InsertEvent(object): def __init__(self, itype, iid, after, destination): @@ -102,6 +107,7 @@ class InsertEvent(object): def toList(self): return ["insert", self.destination, self.type, self.id, self.after] + class ReloadAllEvent(object): def __init__(self, destination): @@ -112,11 +118,13 @@ class ReloadAllEvent(object): def toList(self): return ["reload", self.destination] + class AccountUpdateEvent(object): def toList(self): return ["account"] + class ConfigUpdateEvent(object): def toList(self): -- cgit v1.2.3 From e48abf98766b0a9c5799f17073d867dc09b23663 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 17:54:19 +0200 Subject: PEP-8, Python Zen, refactor and reduce code (part 3 in master module) Conflicts: module/InitHomeDir.py module/debug.py module/forwarder.py module/unescape.py pyload/datatype/Package.py pyload/manager/Event.py pyload/manager/Thread.py pyload/manager/event/Scheduler.py pyload/utils/__init__.py pyload/webui/filters.py --- pyload/manager/Thread.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'pyload/manager') diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py index e24b20d59..b255523d6 100644 --- a/pyload/manager/Thread.py +++ b/pyload/manager/Thread.py @@ -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 range(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+).*")] ip = "" - for i in range(10): + for _i in range(10): try: sv = choice(services) ip = getURL(sv[0]) @@ -285,7 +285,7 @@ class ThreadManager(object): if free and not self.pause: thread = free[0] - #self.downloaded += 1 + # self.downloaded += 1 thread.put(job) else: @@ -299,7 +299,6 @@ class ThreadManager(object): if job: job.initPlugin() thread = DecrypterThread(self, job) - else: thread = DecrypterThread(self, job) -- cgit v1.2.3 From bb5a115533711fd8bb87f53cb32ff7342137208d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Apr 2015 00:29:55 +0200 Subject: Spare code cosmetics (5) --- pyload/manager/Account.py | 9 ++++++--- pyload/manager/Addon.py | 2 -- pyload/manager/Plugin.py | 3 ++- pyload/manager/Remote.py | 1 + pyload/manager/Thread.py | 6 ++++-- 5 files changed, 13 insertions(+), 8 deletions(-) (limited to 'pyload/manager') diff --git a/pyload/manager/Account.py b/pyload/manager/Account.py index 4e4a82aed..44a5e5c65 100644 --- a/pyload/manager/Account.py +++ b/pyload/manager/Account.py @@ -90,9 +90,12 @@ class AccountManager(object): for line in content[1:]: line = line.strip() - if not line: continue - if line.startswith("#"): continue - if line.startswith("version"): continue + if not line: + continue + if line.startswith("#"): + continue + if line.startswith("version"): + continue if line.endswith(":") and line.count(":") == 1: plugin = line[:-1] diff --git a/pyload/manager/Addon.py b/pyload/manager/Addon.py index cf23715b6..5ac56a349 100644 --- a/pyload/manager/Addon.py +++ b/pyload/manager/Addon.py @@ -41,8 +41,6 @@ class AddonManager(object): | Notes: | all_downloads-processed is *always* called before all_downloads-finished. | config-changed is *always* called before pluginConfigChanged. - - """ def __init__(self, core): diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py index e99b1cea6..905ce524e 100644 --- a/pyload/manager/Plugin.py +++ b/pyload/manager/Plugin.py @@ -313,7 +313,8 @@ class PluginManager(object): else: user = 0 # used as bool and int split = fullname.split(".") - if len(split) != 4 - user: return + if len(split) != 4 - user: + return type, name = split[2 - user:4 - user] if type in self.plugins and name in self.plugins[type]: diff --git a/pyload/manager/Remote.py b/pyload/manager/Remote.py index b18035a00..c2d254932 100644 --- a/pyload/manager/Remote.py +++ b/pyload/manager/Remote.py @@ -61,6 +61,7 @@ class RemoteManager(object): # else: # self.available.append("SocketBackend") + def startBackends(self): host = self.core.config.get("remote", "listenaddr") port = self.core.config.get("remote", "port") diff --git a/pyload/manager/Thread.py b/pyload/manager/Thread.py index b255523d6..a8550e504 100644 --- a/pyload/manager/Thread.py +++ b/pyload/manager/Thread.py @@ -250,10 +250,12 @@ class ThreadManager(object): def assignJob(self): """assing a job to a thread if possible""" - if self.pause or not self.core.api.isTimeDownload(): return + if self.pause or not self.core.api.isTimeDownload(): + return # if self.downloaded > 20: - # if not self.cleanPyCurl(): return + # if not self.cleanPyCurl(): + return free = [x for x in self.threads if not x.active] -- cgit v1.2.3