From e2557715e85974c5ec3a1aac4c1dccf21de24a2a Mon Sep 17 00:00:00 2001 From: Vuolter Date: Wed, 15 May 2013 13:41:01 +0200 Subject: Version 1.00: delete finished packages only instead all finished links --- module/plugins/hooks/DeleteFinished.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'module') diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index e0df69eef..29959eb57 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -18,12 +18,13 @@ """ from module.plugins.Hook import Hook +from module.database import style from time import time class DeleteFinished(Hook): __name__ = "DeleteFinished" - __version__ = "0.5" + __version__ = "1.00" __description__ = "Automatically delete finished packages from queue" __config__ = [ ("activated", "bool", "Activated", "False"), @@ -32,6 +33,11 @@ class DeleteFinished(Hook): __author_name__ = ("Walter Purcaro") __author_mail__ = ("vuolter@gmail.com") + @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) @@ -40,8 +46,8 @@ class DeleteFinished(Hook): 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) @@ -72,6 +78,7 @@ class DeleteFinished(Hook): interval = self.getConfig("interval") * 3600 if interval != self.interval: self.interval = interval + self.initPeriodical() def unload(self): # self.logDebug("self.unload") -- cgit v1.2.3 From 79e660e8e87cc47156fb6478d9186750b0cff837 Mon Sep 17 00:00:00 2001 From: Vuolter Date: Wed, 15 May 2013 16:40:15 +0200 Subject: Version 1.01: code cosmetics --- module/plugins/hooks/DeleteFinished.py | 57 +++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'module') 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) -- cgit v1.2.3 From 4ff7c4e72c2733864deb4a507debf024b0e86d74 Mon Sep 17 00:00:00 2001 From: Vuolter Date: Mon, 20 May 2013 22:14:24 +0200 Subject: Version 1.02: removed imported method time --- module/plugins/hooks/DeleteFinished.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'module') diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index e71772eed..01cb1b8e1 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -17,14 +17,13 @@ @author: Walter Purcaro """ -from module.plugins.Hook import Hook from module.database import style -from time import time +from module.plugins.Hook import Hook class DeleteFinished(Hook): __name__ = "DeleteFinished" - __version__ = "1.01" + __version__ = "1.02" __description__ = "Automatically delete finished packages from queue" __config__ = [ ("activated", "bool", "Activated", "False"), @@ -33,7 +32,7 @@ class DeleteFinished(Hook): __author_name__ = ("Walter Purcaro") __author_mail__ = ("vuolter@gmail.com") - ## overwrited methods ## + ## overwritten methods ## def periodical(self): # self.logDebug("self.periodical") if not self.info["sleep"]: -- cgit v1.2.3