From c9c16f69e39580ae7744b05f60268578e6032563 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 5 Jul 2014 22:35:14 +0200 Subject: [RestartFailed] Code cleanup --- module/plugins/hooks/RestartFailed.py | 65 ++++++++++++++++------------------- 1 file changed, 30 insertions(+), 35 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 85553d738..89bbcb19e 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -1,57 +1,52 @@ # -*- coding: utf-8 -*- - -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - @author: Walter Purcaro -""" +############################################################################ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +############################################################################ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" - __version__ = "1.53" + __version__ = "1.54" __description__ = """Periodically restart all failed downloads in queue""" __config__ = [("activated", "bool", "Activated", False), - ("interval", "int", "Interval in minutes", 90)] + ("interval", "int", "Check interval in minutes", 90)] __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" + MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) + event_list = ["pluginConfigChanged"] - MIN_INTERVAL = 15 * 60 # seconds def periodical(self): - self.logDebug("Restart all failed downloads now") + self.logInfo("Restart failed downloads") self.core.api.restartFailed() - def restartPeriodical(self, interval): - self.logDebug("Set periodical interval to %s seconds" % interval) - if self.cb: - self.core.scheduler.removeJob(self.cb) - self.interval = interval - self.cb = self.core.scheduler.addJob(interval, self._periodical, threaded=False) - def pluginConfigChanged(self, plugin, name, value): - value *= 60 - if name == "interval": - if self.interval != value > self.MIN_INTERVAL: - self.restartPeriodical(value) + if name != "interval": + interval = value * 60 + if self.MIN_INTERVAL <= interval != self.interval: + self.core.scheduler.removeJob(self.cb) + self.interval = interval + self.initPeriodical() else: - self.logWarning("Cannot change interval: given value is equal to the current or \ - smaller than %s seconds" % self.MIN_INTERVAL) + self.logWarning("Invalid interval value, kept current") + + def setup(self): + self.interval = self.MIN_INTERVAL def coreReady(self): - self.pluginConfigChanged(plugin="RestartFailed", name="interval", value=self.getConfig("interval")) + self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) -- cgit v1.2.3 From cec2250f13753ea37312a56871cd6acf8d1d09dc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 7 Jul 2014 18:48:27 +0200 Subject: [RestartFailed] Fixed bad interval checking --- module/plugins/hooks/RestartFailed.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 89bbcb19e..3ee2aeed4 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################ +############################################################################### # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the @@ -12,14 +12,14 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -############################################################################ +############################################################################### from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" - __version__ = "1.54" + __version__ = "1.55" __description__ = """Periodically restart all failed downloads in queue""" __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 90)] @@ -31,21 +31,22 @@ class RestartFailed(Hook): event_list = ["pluginConfigChanged"] - def periodical(self): - self.logInfo("Restart failed downloads") - self.core.api.restartFailed() - def pluginConfigChanged(self, plugin, name, value): - if name != "interval": + if name == "interval": interval = value * 60 if self.MIN_INTERVAL <= interval != self.interval: self.core.scheduler.removeJob(self.cb) self.interval = interval self.initPeriodical() else: - self.logWarning("Invalid interval value, kept current") + self.logDebug("Invalid interval value, kept current") + + def periodical(self): + self.logInfo("Restart failed downloads") + self.api.restartFailed() def setup(self): + self.api = self.core.api self.interval = self.MIN_INTERVAL def coreReady(self): -- cgit v1.2.3 From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hooks/RestartFailed.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 3ee2aeed4..2bd0e28db 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -20,9 +20,12 @@ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" __version__ = "1.55" - __description__ = """Periodically restart all failed downloads in queue""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 90)] + + __description__ = """Periodically restart all failed downloads in queue""" __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hooks/RestartFailed.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 2bd0e28db..3aef6f8cd 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -1,26 +1,12 @@ # -*- coding: utf-8 -*- -############################################################################### -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -############################################################################### from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" - __version__ = "1.55" __type__ = "hook" + __version__ = "1.55" __config__ = [("activated", "bool", "Activated", False), ("interval", "int", "Check interval in minutes", 90)] -- cgit v1.2.3 From 0d220d634e512d89bda540f91c643b361c82ea8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Sep 2014 01:38:32 +0200 Subject: Logging string cosmetics --- module/plugins/hooks/RestartFailed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 3aef6f8cd..30c808b4d 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -31,7 +31,7 @@ class RestartFailed(Hook): self.logDebug("Invalid interval value, kept current") def periodical(self): - self.logInfo("Restart failed downloads") + self.logInfo(_("Restart failed downloads")) self.api.restartFailed() def setup(self): -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/hooks/RestartFailed.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 30c808b4d..8e01ee0f1 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -12,13 +12,13 @@ class RestartFailed(Hook): ("interval", "int", "Check interval in minutes", 90)] __description__ = """Periodically restart all failed downloads in queue""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) event_list = ["pluginConfigChanged"] + MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) + def pluginConfigChanged(self, plugin, name, value): if name == "interval": -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/hooks/RestartFailed.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 8e01ee0f1..6724ceaa8 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -12,6 +12,7 @@ class RestartFailed(Hook): ("interval", "int", "Check interval in minutes", 90)] __description__ = """Periodically restart all failed downloads in queue""" + __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/hooks/RestartFailed.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 6724ceaa8..ebce60b3f 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -31,13 +31,16 @@ class RestartFailed(Hook): else: self.logDebug("Invalid interval value, kept current") + def periodical(self): self.logInfo(_("Restart failed downloads")) self.api.restartFailed() + def setup(self): self.api = self.core.api self.interval = self.MIN_INTERVAL + def coreReady(self): self.pluginConfigChanged(self.__name__, "interval", self.getConfig("interval")) -- cgit v1.2.3 From 885f8ed782e64d9e73367905e642a84d0a8999f1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:01:38 +0100 Subject: Update __config__ --- module/plugins/hooks/RestartFailed.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index ebce60b3f..1c2cd1002 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -8,8 +8,7 @@ class RestartFailed(Hook): __type__ = "hook" __version__ = "1.55" - __config__ = [("activated", "bool", "Activated", False), - ("interval", "int", "Check interval in minutes", 90)] + __config__ = [("interval", "int", "Check interval in minutes", 90)] __description__ = """Periodically restart all failed downloads in queue""" __license__ = "GPLv3" -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/hooks/RestartFailed.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 1c2cd1002..4c48c7077 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -4,15 +4,15 @@ from module.plugins.Hook import Hook class RestartFailed(Hook): - __name__ = "RestartFailed" - __type__ = "hook" + __name__ = "RestartFailed" + __type__ = "hook" __version__ = "1.55" __config__ = [("interval", "int", "Check interval in minutes", 90)] __description__ = """Periodically restart all failed downloads in queue""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] event_list = ["pluginConfigChanged"] -- cgit v1.2.3 From 2b8bfcfed0dd32b79a8a3ba95cb84adb5ab22811 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 17:40:39 +0100 Subject: Code cosmetics: use self.core.api instead self.api (for now) --- module/plugins/hooks/RestartFailed.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 4c48c7077..81a83e2c9 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -33,11 +33,10 @@ class RestartFailed(Hook): def periodical(self): self.logInfo(_("Restart failed downloads")) - self.api.restartFailed() + self.core.api.restartFailed() def setup(self): - self.api = self.core.api self.interval = self.MIN_INTERVAL -- cgit v1.2.3 From 4cc95697eface0d00c73d5b39f0cfdf5607f814d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 1 Nov 2014 22:21:58 +0100 Subject: Don't handle bugged event pluginConfigChanged --- module/plugins/hooks/RestartFailed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 81a83e2c9..b866c9d0a 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -6,7 +6,7 @@ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" __type__ = "hook" - __version__ = "1.55" + __version__ = "1.56" __config__ = [("interval", "int", "Check interval in minutes", 90)] @@ -15,7 +15,7 @@ class RestartFailed(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - event_list = ["pluginConfigChanged"] + # event_list = ["pluginConfigChanged"] MIN_INTERVAL = 15 * 60 #: 15m minimum check interval (value is in seconds) -- cgit v1.2.3 From 7add58fd4e712037d0a4b775cda10c7a9e677645 Mon Sep 17 00:00:00 2001 From: Firefly Date: Tue, 4 Nov 2014 14:17:03 +0100 Subject: [RestartFailed] Removed clutter message in normal mode --- module/plugins/hooks/RestartFailed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/RestartFailed.py') diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index b866c9d0a..07fb80967 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -6,7 +6,7 @@ from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" __type__ = "hook" - __version__ = "1.56" + __version__ = "1.57" __config__ = [("interval", "int", "Check interval in minutes", 90)] @@ -32,7 +32,7 @@ class RestartFailed(Hook): def periodical(self): - self.logInfo(_("Restart failed downloads")) + self.logDebug(_("Restart failed downloads")) self.core.api.restartFailed() -- cgit v1.2.3