diff options
author | Vuolter <vuolter@gmail.com> | 2013-05-15 16:40:15 +0200 |
---|---|---|
committer | Vuolter <vuolter@gmail.com> | 2013-05-17 18:26:07 +0200 |
commit | 79e660e8e87cc47156fb6478d9186750b0cff837 (patch) | |
tree | 5cbcd1e16d1686b65cba982d3bd61fb6f8d7e6ce /module | |
parent | Version 1.00: delete finished packages only instead all finished links (diff) | |
download | pyload-79e660e8e87cc47156fb6478d9186750b0cff837.tar.xz |
Version 1.01: code cosmetics
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/hooks/DeleteFinished.py | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 29959eb57..e71772eed 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -24,7 +24,7 @@ from time import time class DeleteFinished(Hook): __name__ = "DeleteFinished" - __version__ = "1.00" + __version__ = "1.01" __description__ = "Automatically delete finished packages from queue" __config__ = [ ("activated", "bool", "Activated", "False"), @@ -33,6 +33,33 @@ class DeleteFinished(Hook): __author_name__ = ("Walter Purcaro") __author_mail__ = ("vuolter@gmail.com") + ## overwrited methods ## + def periodical(self): + # self.logDebug("self.periodical") + if not self.info["sleep"]: + self.logInfo("self.deleteFinished") + self.deleteFinished() + self.info["sleep"] = True + self.addEvent("packageFinished", self.wakeup) + + def pluginConfigChanged(self, plugin, name, value): + # self.logDebug("self.pluginConfigChanged") + if name == "interval" and value != self.interval: + self.interval = value + self.initPeriodical() + + def unload(self): + # self.logDebug("self.unload") + self.removeEvent("packageFinished", self.wakeup) + + def coreReady(self): + # self.logDebug("self.coreReady") + self.info = {"sleep": True} + interval = self.getConfig("interval") * 3600 + self.pluginConfigChanged("DeleteFinished", "interval", interval) + self.addEvent("packageFinished", self.wakeup) + + ## own methods ## @style.queue def deleteFinished(self): self.c.execute("DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE package=packages.id AND status NOT IN (0,4))") @@ -43,14 +70,7 @@ class DeleteFinished(Hook): self.removeEvent("packageFinished", self.wakeup) self.info["sleep"] = False - def periodical(self): - # self.logDebug("self.periodical") - if not self.info["sleep"]: - self.logInfo("self.deleteFinished") - self.deleteFinished() - self.info["sleep"] = True - self.addEvent("packageFinished", self.wakeup) - + ## event managing ## def addEvent(self, event, handler): if event in self.manager.events: if handler not in self.manager.events[event]: @@ -72,22 +92,3 @@ class DeleteFinished(Hook): else: # self.logDebug("self.removeEvent: " + event + ": NOT removed handler") return False - - def configEvents(self, plugin=None, name=None, value=None): - # self.logDebug("self.configEvents") - interval = self.getConfig("interval") * 3600 - if interval != self.interval: - self.interval = interval - self.initPeriodical() - - def unload(self): - # self.logDebug("self.unload") - self.removeEvent("pluginConfigChanged", self.configEvents) - self.removeEvent("packageFinished", self.wakeup) - - def coreReady(self): - # self.logDebug("self.coreReady") - self.info = {"sleep": True} - self.addEvent("pluginConfigChanged", self.configEvents) - self.configEvents() - self.addEvent("packageFinished", self.wakeup) |