diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-04-11 11:34:47 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2014-04-21 17:15:22 +0200 |
commit | 8ee73caaa2f3674918241141faa15414f63ce38b (patch) | |
tree | c57d47dc9af807c7114fdb244c2c1a4af7657198 | |
parent | Crypter: TurbobitNetFolder: Improved _getLinks recursion (diff) | |
download | pyload-8ee73caaa2f3674918241141faa15414f63ce38b.tar.xz |
Hook: RestartFailed: Old version rewritten
Merges vuolter/pyload@47e3ffe
(cherry picked from commit 427be7ed6407ffc542fd9c0f8356a03a2dc5cc28)
-rw-r--r-- | pyload/plugins/addons/RestartFailed.py | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/pyload/plugins/addons/RestartFailed.py b/pyload/plugins/addons/RestartFailed.py index 3bf6fe365..64853194a 100644 --- a/pyload/plugins/addons/RestartFailed.py +++ b/pyload/plugins/addons/RestartFailed.py @@ -1,32 +1,57 @@ # -*- 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 <http://www.gnu.org/licenses/>. + + @author: Walter Purcaro +""" + from module.plugins.Hook import Hook class RestartFailed(Hook): __name__ = "RestartFailed" - __version__ = "1.52" - __description__ = "restartedFailed Packages after defined time" + __version__ = "1.53" + __description__ = "Periodically restart all failed downloads in queue" __config__ = [("activated", "bool", "Activated", "False"), - ("interval", "int", "Interval in Minutes", "15")] - - __author_name__ = ("bambie") - __author_mail__ = ("bambie@gulli.com") + ("interval", "int", "Interval in minutes", "90")] + __author_name__ = ("Walter Purcaro") + __author_mail__ = ("vuolter@gmail.com") - interval = 300 + event_list = ["pluginConfigChanged"] - def setup(self): - self.info = {"running": False} - - def coreReady(self): - self.info["running"] = True - self.logInfo("loaded") - self.interval = self.getConfig("interval") * 60 - self.logDebug("interval is set to %s" % self.interval) + MIN_INTERVAL = 15 * 60 #seconds def periodical(self): - self.logDebug("periodical called") - if self.getConfig("interval") * 60 != self.interval: - self.interval = self.getConfig("interval") * 60 - self.logDebug("interval is set to %s" % self.interval) + self.logDebug("Restart all failed downloads now") 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) + else: + self.logWarning("Cannot change interval: given value is equal to the current or \ + smaller than %s seconds" % self.MIN_INTERVAL) + + def coreReady(self): + self.pluginConfigChanged(plugin="RestartFailed", name="interval", value=self.getConfig("interval")) |