diff options
author | Stefano <l.stickell@yahoo.it> | 2013-05-20 23:54:07 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-05-20 23:54:07 +0200 |
commit | 94fc380ceaac6f8fc3a346a9adbf60aeaea6f5b9 (patch) | |
tree | 29502dace066cb9d7659785ce0b91d1367b577b6 | |
parent | CloudzerNet: reconnect support (diff) | |
parent | Version 1.02: removed imported method time (diff) | |
download | pyload-94fc380ceaac6f8fc3a346a9adbf60aeaea6f5b9.tar.xz |
Merge pull request #121 from vuolter/plugin/DeleteFinished
DeleteFinished: plugin updated
-rw-r--r-- | module/plugins/hooks/DeleteFinished.py | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index e0df69eef..01cb1b8e1 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -17,13 +17,13 @@ @author: Walter Purcaro """ +from module.database import style from module.plugins.Hook import Hook -from time import time class DeleteFinished(Hook): __name__ = "DeleteFinished" - __version__ = "0.5" + __version__ = "1.02" __description__ = "Automatically delete finished packages from queue" __config__ = [ ("activated", "bool", "Activated", "False"), @@ -32,19 +32,44 @@ class DeleteFinished(Hook): __author_name__ = ("Walter Purcaro") __author_mail__ = ("vuolter@gmail.com") - def wakeup(self, pypack): - # self.logDebug("self.wakeup") - self.removeEvent("packageFinished", self.wakeup) - self.info["sleep"] = False - + ## overwritten methods ## def periodical(self): # self.logDebug("self.periodical") if not self.info["sleep"]: - self.core.api.deleteFinished() - self.logDebug("called self.core.api.deleteFinished") + 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))") + self.c.execute("DELETE FROM links WHERE NOT EXISTS(SELECT 1 FROM packages WHERE id=links.package)") + + def wakeup(self, pypack): + # self.logDebug("self.wakeup") + self.removeEvent("packageFinished", self.wakeup) + self.info["sleep"] = False + + ## event managing ## def addEvent(self, event, handler): if event in self.manager.events: if handler not in self.manager.events[event]: @@ -66,21 +91,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 - - 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) |