diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-10-03 19:58:50 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-10-03 19:58:50 +0200 |
commit | 56f75b634356602c5f7a93f65a1260fe2c0d66d8 (patch) | |
tree | 0a4cea353074894d031286d09ccde72c2bc53f25 /pyload/plugins/hooks/DeleteFinished.py | |
parent | Rename accounts directory to account (diff) | |
download | pyload-56f75b634356602c5f7a93f65a1260fe2c0d66d8.tar.xz |
Rename hooks directory to addon
Diffstat (limited to 'pyload/plugins/hooks/DeleteFinished.py')
-rw-r--r-- | pyload/plugins/hooks/DeleteFinished.py | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/pyload/plugins/hooks/DeleteFinished.py b/pyload/plugins/hooks/DeleteFinished.py deleted file mode 100644 index 6da42c4e3..000000000 --- a/pyload/plugins/hooks/DeleteFinished.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyload.database import style -from pyload.plugins.base.Hook import Hook - - -class DeleteFinished(Hook): - __name__ = "DeleteFinished" - __type__ = "hook" - __version__ = "1.09" - - __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""" - __author_name__ = "Walter Purcaro" - __author_mail__ = "vuolter@gmail.com" - - - ## overwritten methods ## - def periodical(self): - if not self.info['sleep']: - deloffline = self.getConfig('deloffline') - mode = '0,1,4' if deloffline else '0,4' - msg = _('delete all finished packages in queue list (%s packages with offline links)') - self.logInfo(msg % (_('including') if deloffline else _('excluding'))) - self.deleteFinished(mode) - self.info['sleep'] = True - self.addEvent('packageFinished', self.wakeup) - - def pluginConfigChanged(self, plugin, name, value): - if name == 'interval' and value != self.interval: - self.interval = value * 3600 - self.initPeriodical() - - def unload(self): - self.removeEvent('packageFinished', self.wakeup) - - def coreReady(self): - self.info = {'sleep': True} - interval = self.getConfig('interval') - self.pluginConfigChanged('DeleteFinished', 'interval', interval) - self.addEvent('packageFinished', self.wakeup) - - ## own methods ## - @style.queue - def deleteFinished(self, mode): - self.c.execute('DELETE FROM packages WHERE NOT EXISTS(SELECT 1 FROM links WHERE package=packages.id AND status NOT IN (%s))' % mode) - self.c.execute('DELETE FROM links WHERE NOT EXISTS(SELECT 1 FROM packages WHERE id=links.package)') - - def wakeup(self, pypack): - self.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]: - self.logDebug("Function already registered", func) - else: - self.m.events[event].append(func) - else: - self.m.events[event] = [func] - - def setup(self): - self.m = self.manager - self.removeEvent = self.m.removeEvent |