From 0e1ef9bc01579328e17e79416fa3c1c7b77adcc8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 8 Jun 2015 06:08:01 +0200 Subject: Update everything --- module/plugins/hooks/DownloadScheduler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 9c74ac1d4..314e5913e 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -3,13 +3,13 @@ import re import time -from module.plugins.Hook import Hook +from module.plugins.internal.Hook import Hook class DownloadScheduler(Hook): __name__ = "DownloadScheduler" __type__ = "hook" - __version__ = "0.22" + __version__ = "0.23" __config__ = [("timetable", "str", "List time periods as hh:mm full or number(kB/s)", "0:00 full, 7:00 250, 10:00 0, 17:00 150"), -- cgit v1.2.3 From c9144f451b74e4d3cc67935b9e73c662ac870c6e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 07:18:39 +0200 Subject: Hook plugin code cosmetics (2) --- module/plugins/hooks/DownloadScheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 314e5913e..773de7c4b 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -29,7 +29,7 @@ class DownloadScheduler(Hook): self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded - def coreReady(self): + def activate(self): self.updateSchedule() -- cgit v1.2.3 From 20b6a2ec022202b0efb6cb69415239fb8f4d1445 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:59:20 +0200 Subject: Spare code cosmetics (2) --- module/plugins/hooks/DownloadScheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 773de7c4b..0ccc8a0ec 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -26,7 +26,7 @@ class DownloadScheduler(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded + self.cb = None #: callback to scheduler job; will be by removed hookmanager when hook unloaded def activate(self): -- cgit v1.2.3 From e4fb45b22d36595839e8f638a3f0a4669dba3e8d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 21 Jun 2015 08:50:26 +0200 Subject: Spare code cosmetics (4) --- module/plugins/hooks/DownloadScheduler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 0ccc8a0ec..aa0ccbbab 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -11,9 +11,8 @@ class DownloadScheduler(Hook): __type__ = "hook" __version__ = "0.23" - __config__ = [("timetable", "str", "List time periods as hh:mm full or number(kB/s)", - "0:00 full, 7:00 250, 10:00 0, 17:00 150"), - ("abort", "bool", "Abort active downloads when start period with speed 0", False)] + __config__ = [("timetable", "str" , "List time periods as hh:mm full or number(kB/s)" , "0:00 full, 7:00 250, 10:00 0, 17:00 150"), + ("abort" , "bool", "Abort active downloads when start period with speed 0", False )] __description__ = """Download Scheduler""" __license__ = "GPLv3" -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/hooks/DownloadScheduler.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index aa0ccbbab..e4b09f049 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -9,7 +9,7 @@ from module.plugins.internal.Hook import Hook class DownloadScheduler(Hook): __name__ = "DownloadScheduler" __type__ = "hook" - __version__ = "0.23" + __version__ = "0.24" __config__ = [("timetable", "str" , "List time periods as hh:mm full or number(kB/s)" , "0:00 full, 7:00 250, 10:00 0, 17:00 150"), ("abort" , "bool", "Abort active downloads when start period with speed 0", False )] @@ -29,41 +29,41 @@ class DownloadScheduler(Hook): def activate(self): - self.updateSchedule() + self.update_schedule() - def updateSchedule(self, schedule=None): + def update_schedule(self, schedule=None): if schedule is None: - schedule = self.getConfig('timetable') + schedule = self.get_config('timetable') schedule = re.findall("(\d{1,2}):(\d{2})[\s]*(-?\d+)", schedule.lower().replace("full", "-1").replace("none", "0")) if not schedule: - self.logError(_("Invalid schedule")) + self.log_error(_("Invalid schedule")) return t0 = time.localtime() now = (t0.tm_hour, t0.tm_min, t0.tm_sec, "X") schedule = sorted([(int(x[0]), int(x[1]), 0, int(x[2])) for x in schedule] + [now]) - self.logDebug("Schedule", schedule) + self.log_debug("Schedule", schedule) for i, v in enumerate(schedule): if v[3] == "X": last, next = schedule[i - 1], schedule[(i + 1) % len(schedule)] - self.logDebug("Now/Last/Next", now, last, next) + self.log_debug("Now/Last/Next", now, last, next) - self.setDownloadSpeed(last[3]) + self.set_download_speed(last[3]) next_time = (((24 + next[0] - now[0]) * 60 + next[1] - now[1]) * 60 + next[2] - now[2]) % 86400 self.core.scheduler.removeJob(self.cb) - self.cb = self.core.scheduler.addJob(next_time, self.updateSchedule, threaded=False) + self.cb = self.core.scheduler.addJob(next_time, self.update_schedule, threaded=False) - def setDownloadSpeed(self, speed): + def set_download_speed(self, speed): if speed == 0: - abort = self.getConfig('abort') - self.logInfo(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) + abort = self.get_config('abort') + self.log_info(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) self.core.api.pauseServer() if abort: self.core.api.stopAllDownloads() @@ -71,10 +71,10 @@ class DownloadScheduler(Hook): self.core.api.unpauseServer() if speed > 0: - self.logInfo(_("Setting download speed to %d kB/s") % speed) + self.log_info(_("Setting download speed to %d kB/s") % speed) self.core.api.setConfigValue("download", "limit_speed", 1) self.core.api.setConfigValue("download", "max_speed", speed) else: - self.logInfo(_("Setting download speed to FULL")) + self.log_info(_("Setting download speed to FULL")) self.core.api.setConfigValue("download", "limit_speed", 0) self.core.api.setConfigValue("download", "max_speed", -1) -- cgit v1.2.3 From d2e2b127651a5a44b56337eb6d9ca246c97a208a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Jul 2015 03:03:26 +0200 Subject: Spare fixes and code cosmetics --- module/plugins/hooks/DownloadScheduler.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index e4b09f049..ed43683fa 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -72,9 +72,9 @@ class DownloadScheduler(Hook): if speed > 0: self.log_info(_("Setting download speed to %d kB/s") % speed) - self.core.api.setConfigValue("download", "limit_speed", 1) - self.core.api.setConfigValue("download", "max_speed", speed) + self.core.config.set("download", "limit_speed", 1) + self.core.config.set("download", "max_speed", speed) else: self.log_info(_("Setting download speed to FULL")) - self.core.api.setConfigValue("download", "limit_speed", 0) - self.core.api.setConfigValue("download", "max_speed", -1) + self.core.config.set("download", "limit_speed", 0) + self.core.config.set("download", "max_speed", -1) -- cgit v1.2.3 From dad722ac7255640e7e0541c4094a4d2e4de79cd3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 00:05:58 +0200 Subject: Code cosmetics (2) --- module/plugins/hooks/DownloadScheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index ed43683fa..e1114d615 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -25,7 +25,7 @@ class DownloadScheduler(Hook): def setup(self): self.info = {} #@TODO: Remove in 0.4.10 - self.cb = None #: callback to scheduler job; will be by removed hookmanager when hook unloaded + self.cb = None #: Callback to scheduler job; will be by removed hookmanager when hook unloaded def activate(self): -- cgit v1.2.3 From 502517f37c7540b0bddb092e69386d9d6f08800c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 09:42:34 +0200 Subject: Fix addons --- module/plugins/hooks/DownloadScheduler.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index e1114d615..bd67dec67 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -3,10 +3,10 @@ import re import time -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class DownloadScheduler(Hook): +class DownloadScheduler(Addon): __name__ = "DownloadScheduler" __type__ = "hook" __version__ = "0.24" @@ -20,14 +20,6 @@ class DownloadScheduler(Hook): ("stickell", "l.stickell@yahoo.it")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.cb = None #: Callback to scheduler job; will be by removed hookmanager when hook unloaded - - def activate(self): self.update_schedule() -- cgit v1.2.3 From 56389e28ba5d2f5658278bc7f486d73be747f135 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 11:44:49 +0200 Subject: Rename self.core to self.pyload (plugins only) --- module/plugins/hooks/DownloadScheduler.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index bd67dec67..c32088532 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -48,25 +48,25 @@ class DownloadScheduler(Addon): self.set_download_speed(last[3]) next_time = (((24 + next[0] - now[0]) * 60 + next[1] - now[1]) * 60 + next[2] - now[2]) % 86400 - self.core.scheduler.removeJob(self.cb) - self.cb = self.core.scheduler.addJob(next_time, self.update_schedule, threaded=False) + self.pyload.scheduler.removeJob(self.cb) + self.cb = self.pyload.scheduler.addJob(next_time, self.update_schedule, threaded=False) def set_download_speed(self, speed): if speed == 0: abort = self.get_config('abort') self.log_info(_("Stopping download server. (Running downloads will %sbe aborted.)") % '' if abort else _('not ')) - self.core.api.pauseServer() + self.pyload.api.pauseServer() if abort: - self.core.api.stopAllDownloads() + self.pyload.api.stopAllDownloads() else: - self.core.api.unpauseServer() + self.pyload.api.unpauseServer() if speed > 0: self.log_info(_("Setting download speed to %d kB/s") % speed) - self.core.config.set("download", "limit_speed", 1) - self.core.config.set("download", "max_speed", speed) + self.pyload.config.set("download", "limit_speed", 1) + self.pyload.config.set("download", "max_speed", speed) else: self.log_info(_("Setting download speed to FULL")) - self.core.config.set("download", "limit_speed", 0) - self.core.config.set("download", "max_speed", -1) + self.pyload.config.set("download", "limit_speed", 0) + self.pyload.config.set("download", "max_speed", -1) -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/hooks/DownloadScheduler.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index c32088532..7c24a41db 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -10,6 +10,7 @@ class DownloadScheduler(Addon): __name__ = "DownloadScheduler" __type__ = "hook" __version__ = "0.24" + __status__ = "stable" __config__ = [("timetable", "str" , "List time periods as hh:mm full or number(kB/s)" , "0:00 full, 7:00 250, 10:00 0, 17:00 150"), ("abort" , "bool", "Abort active downloads when start period with speed 0", False )] -- cgit v1.2.3 From 94d017cd2a5c1f194960827a8c7e46afc3682008 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 06:55:49 +0200 Subject: Hotfixes (2) --- module/plugins/hooks/DownloadScheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DownloadScheduler.py') diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 7c24a41db..b2e804dce 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -10,7 +10,7 @@ class DownloadScheduler(Addon): __name__ = "DownloadScheduler" __type__ = "hook" __version__ = "0.24" - __status__ = "stable" + __status__ = "testing" __config__ = [("timetable", "str" , "List time periods as hh:mm full or number(kB/s)" , "0:00 full, 7:00 250, 10:00 0, 17:00 150"), ("abort" , "bool", "Abort active downloads when start period with speed 0", False )] -- cgit v1.2.3