diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-21 17:17:03 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-03-21 17:17:03 +0100 |
commit | b9219fa1859de12de010a07c4c92a9f0270042ac (patch) | |
tree | f5b6aa872f47beb3319c0d1c0fd403f141613f4b | |
parent | [SimpleHoster] Fix checkErrors (2) (diff) | |
download | pyload-b9219fa1859de12de010a07c4c92a9f0270042ac.tar.xz |
[DeleteFinished] Define MIN_CHECK_INTERVAL
-rw-r--r-- | module/plugins/hooks/DeleteFinished.py | 38 | ||||
-rw-r--r-- | module/plugins/hooks/RestartFailed.py | 5 |
2 files changed, 23 insertions, 20 deletions
diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 3dff9c7bd..75cb33e96 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -7,11 +7,11 @@ from module.plugins.Hook import Hook class DeleteFinished(Hook): __name__ = "DeleteFinished" __type__ = "hook" - __version__ = "1.11" + __version__ = "1.12" - __config__ = [('activated', 'bool', 'Activated', 'False'), - ('interval', 'int', 'Delete every (hours)', '72'), - ('deloffline', 'bool', 'Delete packages with offline links', 'False')] + __config__ = [("activated" , "bool", "Activated" , "False"), + ("interval" , "int" , "Delete every (hours)" , "72" ), + ("deloffline", "bool", "Delete packages with offline links", "False")] __description__ = """Automatically delete all finished packages from queue""" __license__ = "GPLv3" @@ -20,8 +20,15 @@ class DeleteFinished(Hook): # event_list = ["pluginConfigChanged"] + MIN_CHECK_INTERVAL = 1 * 60 * 60 #: 1 hour + ## overwritten methods ## + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + self.interval = self.MIN_CHECK_INTERVAL + + def periodical(self): if not self.info['sleep']: deloffline = self.getConfig('deloffline') @@ -40,13 +47,14 @@ class DeleteFinished(Hook): def unload(self): - self.removeEvent('packageFinished', self.wakeup) + self.manager.removeEvent('packageFinished', self.wakeup) def coreReady(self): self.info['sleep'] = True - interval = self.getConfig('interval') - self.pluginConfigChanged(self.__name__, 'interval', interval) + # interval = self.getConfig('interval') + # self.pluginConfigChanged(self.__name__, 'interval', interval) + self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60 * 60) self.addEvent('packageFinished', self.wakeup) @@ -58,23 +66,17 @@ class DeleteFinished(Hook): def wakeup(self, pypack): - self.removeEvent('packageFinished', self.wakeup) + self.manager.removeEvent('packageFinished', self.wakeup) self.info['sleep'] = False ## event managing ## def addEvent(self, event, func): """Adds an event listener for event name""" - if event in self.m.events: - if func in self.m.events[event]: + if event in self.manager.events: + if func in self.manager.events[event]: self.logDebug("Function already registered", func) else: - self.m.events[event].append(func) + self.manager.events[event].append(func) else: - self.m.events[event] = [func] - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.m = self.manager - self.removeEvent = self.m.removeEvent + self.manager.events[event] = [func] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index c861e9c41..cab986d9e 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.57" + __version__ = "1.58" __config__ = [("interval", "int", "Check interval in minutes", 90)] @@ -42,4 +42,5 @@ class RestartFailed(Hook): def coreReady(self): - self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + # self.pluginConfigChanged(self.__name__, "interval", self.getConfig('interval')) + self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60) |