From 9ad979dc5b3753e2982855495b240b3da37c3be4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 2 Dec 2014 12:37:56 +0100 Subject: [SkipRev] Updated --- module/plugins/hooks/SkipRev.py | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 module/plugins/hooks/SkipRev.py (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py new file mode 100644 index 000000000..3b3b450fe --- /dev/null +++ b/module/plugins/hooks/SkipRev.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.Hook import Hook +from module.plugins.Plugin import SkipDownload + + +class SkipRev(Hook): + __name__ = "SkipRev" + __type__ = "hook" + __version__ = "0.08" + + __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True) + ("tokeep", "int" , "Min number of rev files to keep for package" , 1), + ("unskip", "bool", "Restart a skipped rev when download fails" , True)] + + __description__ = """Skip files ending with extension rev""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + event_map = [("downloadStarts", skipRev)] + + REV = re.compile(r'\.part(\d+)\.rev$') + + + def skipRev(self, pyfile, url, filename): + if REV.search(pyfile.name) is None or pyfile.getStatusName is "unskipped": + return + + tokeep = self.getConfig("tokeep") + + if tokeep > 0: + saved = [True if link.hasStatus("finished") or link.hasStatus("downloading") and REV.search(link.name) \ + for link in pyfile.package().getChildren()].count(True) + + if saved < tokeep: + return + + raise SkipDownload("SkipRev") + + + def downloadFailed(self, pyfile): + if self.getConfig("auto") is False: + + if self.getConfig("unskip") is False: + return + + if REV.search(pyfile.name) is None: + return + + for link in pyfile.package().getChildren(): + if link.hasStatus("skipped") and REV.search(link.name): + link.setCustomStatus("unskipped", "queued") + break -- cgit v1.2.3 From a611ddfd1d8e4a85b2066cc45bc51682ac10a5f7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 2 Dec 2014 16:35:12 +0100 Subject: [SkipRev] Fixup 1 --- module/plugins/hooks/SkipRev.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 3b3b450fe..e9cfa2ec5 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -9,10 +9,10 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.08" + __version__ = "0.09" - __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True) - ("tokeep", "int" , "Min number of rev files to keep for package" , 1), + __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True), + ("tokeep", "int" , "Min number of rev files to keep for package" , 1), ("unskip", "bool", "Restart a skipped rev when download fails" , True)] __description__ = """Skip files ending with extension rev""" @@ -53,4 +53,4 @@ class SkipRev(Hook): for link in pyfile.package().getChildren(): if link.hasStatus("skipped") and REV.search(link.name): link.setCustomStatus("unskipped", "queued") - break + return -- cgit v1.2.3 From a5a6cc0643c562a0d3e55a8577b4fc391009ff2b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 2 Dec 2014 17:00:36 +0100 Subject: [SkipRev] Typo --- module/plugins/hooks/SkipRev.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index e9cfa2ec5..a64f1a83b 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -9,7 +9,7 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True), ("tokeep", "int" , "Min number of rev files to keep for package" , 1), @@ -26,7 +26,7 @@ class SkipRev(Hook): def skipRev(self, pyfile, url, filename): - if REV.search(pyfile.name) is None or pyfile.getStatusName is "unskipped": + if REV.search(pyfile.name) is None or pyfile.getStatusName() is "unskipped": return tokeep = self.getConfig("tokeep") -- cgit v1.2.3 From 69add4e0f3df7f078eafa022e9a59ac21cfaa19b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 3 Dec 2014 00:28:06 +0100 Subject: [SkipRev] Syntax fixes --- module/plugins/hooks/SkipRev.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a64f1a83b..feed16a2b 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -9,7 +9,7 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.10" + __version__ = "0.11" __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True), ("tokeep", "int" , "Min number of rev files to keep for package" , 1), @@ -20,20 +20,20 @@ class SkipRev(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - event_map = [("downloadStarts", skipRev)] + event_list = ["downloadStarts"] REV = re.compile(r'\.part(\d+)\.rev$') - def skipRev(self, pyfile, url, filename): - if REV.search(pyfile.name) is None or pyfile.getStatusName() is "unskipped": + def downloadStarts(self, pyfile, url, filename): + if self.REV.search(pyfile.name) is None or pyfile.getStatusName() is "unskipped": return tokeep = self.getConfig("tokeep") if tokeep > 0: - saved = [True if link.hasStatus("finished") or link.hasStatus("downloading") and REV.search(link.name) \ - for link in pyfile.package().getChildren()].count(True) + saved = [True for link in pyfile.package().getChildren() \ + if link.hasStatus("finished") or link.hasStatus("downloading") and self.REV.search(link.name)].count(True) if saved < tokeep: return @@ -47,10 +47,10 @@ class SkipRev(Hook): if self.getConfig("unskip") is False: return - if REV.search(pyfile.name) is None: + if self.REV.search(pyfile.name) is None: return for link in pyfile.package().getChildren(): - if link.hasStatus("skipped") and REV.search(link.name): + if link.hasStatus("skipped") and self.REV.search(link.name): link.setCustomStatus("unskipped", "queued") return -- cgit v1.2.3 From 7c4c7d4d124b790843ccf6e8150866016e9847a9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 6 Dec 2014 18:11:58 +0100 Subject: [SkipRev] Update --- module/plugins/hooks/SkipRev.py | 42 ++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index feed16a2b..a44d20a3e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -2,6 +2,9 @@ import re +from urllib import unquote +from urlparse import urljoin, urlparse + from module.plugins.Hook import Hook from module.plugins.Plugin import SkipDownload @@ -9,7 +12,7 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.11" + __version__ = "0.12" __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True), ("tokeep", "int" , "Min number of rev files to keep for package" , 1), @@ -20,25 +23,46 @@ class SkipRev(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - event_list = ["downloadStarts"] + def _setup(self): + super(self.pyfile.plugin, self).setup() + if self.pyfile.hasStatus("skipped"): + raise SkipDownload(self.pyfile.getStatusName()) + + + def pyname(self, pyfile): + plugin = pyfile.plugin + + if hasattr(plugin, "info") and 'name' in plugin.info and plugin.info['name']: + name = plugin.info['name'] + + elif hasattr(plugin, "parseInfo"): + name = next(plugin.parseInfo([pyfile.url]))['name'] + + elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfo was not found, getInfo should be missing too + name = plugin.getInfo(pyfile.url)['name'] + + else: + self.logWarning("Unable to grab file name") + name = urlparse(unquote(pyfile.url)).path.split('/')[-1]) - REV = re.compile(r'\.part(\d+)\.rev$') + return name - def downloadStarts(self, pyfile, url, filename): - if self.REV.search(pyfile.name) is None or pyfile.getStatusName() is "unskipped": + def downloadPreparing(self, pyfile): + if pyfile.getStatusName() is "unskipped" or not pyname(pyfile).endswith(".rev"): return tokeep = self.getConfig("tokeep") if tokeep > 0: saved = [True for link in pyfile.package().getChildren() \ - if link.hasStatus("finished") or link.hasStatus("downloading") and self.REV.search(link.name)].count(True) + if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True) if saved < tokeep: return - raise SkipDownload("SkipRev") + pyfile.setCustomStatus("SkipRev", "skipped") + pyfile.plugin.setup = _setup #: work-around: inject status checker inside the preprocessing routine of the plugin def downloadFailed(self, pyfile): @@ -47,10 +71,10 @@ class SkipRev(Hook): if self.getConfig("unskip") is False: return - if self.REV.search(pyfile.name) is None: + if not pyfile.name.endswith(".rev"): return for link in pyfile.package().getChildren(): - if link.hasStatus("skipped") and self.REV.search(link.name): + if link.hasStatus("skipped") and link.name.endswith(".rev"): link.setCustomStatus("unskipped", "queued") return -- cgit v1.2.3 From 2e35201317a88f87b7a0e0ff448f3f55eb1861a9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 7 Dec 2014 14:54:27 +0100 Subject: [SkipRev] Tiny fixup --- module/plugins/hooks/SkipRev.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index a44d20a3e..76a48a255 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -12,7 +12,7 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.12" + __version__ = "0.13" __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True), ("tokeep", "int" , "Min number of rev files to keep for package" , 1), @@ -26,24 +26,25 @@ class SkipRev(Hook): def _setup(self): super(self.pyfile.plugin, self).setup() if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.getStatusName()) + raise SkipDownload(self.pyfile.getStatusName() or self.pyfile.pluginname) def pyname(self, pyfile): + url = pyfile.url plugin = pyfile.plugin if hasattr(plugin, "info") and 'name' in plugin.info and plugin.info['name']: name = plugin.info['name'] elif hasattr(plugin, "parseInfo"): - name = next(plugin.parseInfo([pyfile.url]))['name'] + name = next(plugin.parseInfo([url]))['name'] elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfo was not found, getInfo should be missing too - name = plugin.getInfo(pyfile.url)['name'] + name = plugin.getInfo(url)['name'] else: self.logWarning("Unable to grab file name") - name = urlparse(unquote(pyfile.url)).path.split('/')[-1]) + name = urlparse(unquote(url)).path.split('/')[-1]) return name -- cgit v1.2.3 From 78e26bfd3b940034748256e4d0237e0ae5d33d60 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 8 Dec 2014 23:19:08 +0100 Subject: [SkipRev] Update (2) --- module/plugins/hooks/SkipRev.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 76a48a255..f3edcc9dc 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- -import re - from urllib import unquote -from urlparse import urljoin, urlparse +from urlparse import urlparse from module.plugins.Hook import Hook from module.plugins.Plugin import SkipDownload @@ -12,11 +10,9 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.13" + __version__ = "0.14" - __config__ = [("auto", "bool", "Automatically keep all rev files needed by package", True), - ("tokeep", "int" , "Min number of rev files to keep for package" , 1), - ("unskip", "bool", "Restart a skipped rev when download fails" , True)] + __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] __description__ = """Skip files ending with extension rev""" __license__ = "GPLv3" @@ -55,11 +51,11 @@ class SkipRev(Hook): tokeep = self.getConfig("tokeep") - if tokeep > 0: + if tokeep: saved = [True for link in pyfile.package().getChildren() \ if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True) - if saved < tokeep: + if not saved or saved < tokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") @@ -67,15 +63,15 @@ class SkipRev(Hook): def downloadFailed(self, pyfile): - if self.getConfig("auto") is False: - - if self.getConfig("unskip") is False: - return + tokeep = self.getConfig("tokeep") - if not pyfile.name.endswith(".rev"): - return + if not tokeep: + return for link in pyfile.package().getChildren(): if link.hasStatus("skipped") and link.name.endswith(".rev"): - link.setCustomStatus("unskipped", "queued") + if tokeep > -1 or pyfile.name.endswith(".rev"): + link.setStatus("queued") + else: + link.setCustomStatus("unskipped", "queued") return -- cgit v1.2.3 From e4c9e4ffc9e3f6bd6b16ce83796dc3d275d544f7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 9 Dec 2014 01:13:05 +0100 Subject: Don't start unused periodical in some addons --- module/plugins/hooks/SkipRev.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index f3edcc9dc..609bb4197 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -19,6 +19,11 @@ class SkipRev(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + def _setup(self): super(self.pyfile.plugin, self).setup() if self.pyfile.hasStatus("skipped"): -- cgit v1.2.3 From 430092f0ba67e4bb2dd75433b08340d0afca0fa9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 12 Dec 2014 20:34:42 +0100 Subject: Update plugins after SimpleHoster changes --- module/plugins/hooks/SkipRev.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 609bb4197..107740a3d 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -10,7 +10,7 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.14" + __version__ = "0.15" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -37,10 +37,10 @@ class SkipRev(Hook): if hasattr(plugin, "info") and 'name' in plugin.info and plugin.info['name']: name = plugin.info['name'] - elif hasattr(plugin, "parseInfo"): - name = next(plugin.parseInfo([url]))['name'] + elif hasattr(plugin, "parseInfos"): + name = next(plugin.parseInfos([url]))['name'] - elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfo was not found, getInfo should be missing too + elif hasattr(plugin, "getInfo"): #@NOTE: if parseInfos was not found, getInfo should be missing too name = plugin.getInfo(url)['name'] else: -- cgit v1.2.3 From 3d27f5ccee412d38102873a5b02e3f236375eb97 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Dec 2014 03:44:15 +0100 Subject: Update plugins (2) --- module/plugins/hooks/SkipRev.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 107740a3d..d21aa0f6d 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -10,7 +10,7 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.15" + __version__ = "0.16" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -45,13 +45,13 @@ class SkipRev(Hook): else: self.logWarning("Unable to grab file name") - name = urlparse(unquote(url)).path.split('/')[-1]) + name = urlparse(unquote(url)).path.split('/')[-1] return name def downloadPreparing(self, pyfile): - if pyfile.getStatusName() is "unskipped" or not pyname(pyfile).endswith(".rev"): + if pyfile.getStatusName() is "unskipped" or not self.pyname(pyfile).endswith(".rev"): return tokeep = self.getConfig("tokeep") -- cgit v1.2.3 From bc47c7282b093eabe70d7a04bb481789e4cebf65 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Dec 2014 23:03:48 +0100 Subject: [SkipRev] Another fix --- module/plugins/hooks/SkipRev.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index d21aa0f6d..0c38ac9af 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -10,7 +10,7 @@ from module.plugins.Plugin import SkipDownload class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.16" + __version__ = "0.17" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -57,7 +57,7 @@ class SkipRev(Hook): tokeep = self.getConfig("tokeep") if tokeep: - saved = [True for link in pyfile.package().getChildren() \ + saved = [True for link in self.core.api.getPackageData(pyfile.packageid).links \ if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True) if not saved or saved < tokeep: #: keep one rev at least in auto mode @@ -73,7 +73,7 @@ class SkipRev(Hook): if not tokeep: return - for link in pyfile.package().getChildren(): + for link in self.core.api.getPackageData(pyfile.packageid).links: if link.hasStatus("skipped") and link.name.endswith(".rev"): if tokeep > -1 or pyfile.name.endswith(".rev"): link.setStatus("queued") -- cgit v1.2.3 From d18ae2d67b9aaf3725c6004e4a83efd2774de397 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 23 Dec 2014 22:13:11 +0100 Subject: [SkipRev] Now should work fine... --- module/plugins/hooks/SkipRev.py | 49 +++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 0c38ac9af..2a971bb7c 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -1,16 +1,24 @@ # -*- coding: utf-8 -*- +from types import MethodType from urllib import unquote from urlparse import urlparse +from module.PyFile import PyFile from module.plugins.Hook import Hook from module.plugins.Plugin import SkipDownload +def _setup(self): + self.pyfile.plugin._setup() + if self.pyfile.hasStatus("skipped"): + raise SkipDownload(self.pyfile.self.statusname or self.pyfile.pluginname) + + class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.17" + __version__ = "0.20" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -24,13 +32,7 @@ class SkipRev(Hook): pass - def _setup(self): - super(self.pyfile.plugin, self).setup() - if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.getStatusName() or self.pyfile.pluginname) - - - def pyname(self, pyfile): + def _pyname(self, pyfile): url = pyfile.url plugin = pyfile.plugin @@ -50,21 +52,35 @@ class SkipRev(Hook): return name + def _pyfile(self, link): + return PyFile(self.core.files, + link.fid, + link.url, + link.name, + link.size, + link.status, + link.error, + link.plugin, + link.packageID, + link.order) + + def downloadPreparing(self, pyfile): - if pyfile.getStatusName() is "unskipped" or not self.pyname(pyfile).endswith(".rev"): + if pyfile.statusname is "unskipped" or not self._pyname(pyfile).endswith(".rev"): return tokeep = self.getConfig("tokeep") if tokeep: saved = [True for link in self.core.api.getPackageData(pyfile.packageid).links \ - if link.name.endswith(".rev") and (link.hasStatus("finished") or link.hasStatus("downloading"))].count(True) + if link.name.endswith(".rev") and link.status in (0, 12)].count(True) if not saved or saved < tokeep: #: keep one rev at least in auto mode return pyfile.setCustomStatus("SkipRev", "skipped") - pyfile.plugin.setup = _setup #: work-around: inject status checker inside the preprocessing routine of the plugin + pyfile.plugin._setup = pyfile.plugin.setup + pyfile.plugin.setup = MethodType(_setup, pyfile.plugin) #: work-around: inject status checker inside the preprocessing routine of the plugin def downloadFailed(self, pyfile): @@ -74,9 +90,14 @@ class SkipRev(Hook): return for link in self.core.api.getPackageData(pyfile.packageid).links: - if link.hasStatus("skipped") and link.name.endswith(".rev"): + if link.status is 4 and link.name.endswith(".rev"): + pylink = self._pyfile(link) + if tokeep > -1 or pyfile.name.endswith(".rev"): - link.setStatus("queued") + pylink.setStatus("queued") else: - link.setCustomStatus("unskipped", "queued") + pylink.setCustomStatus("unskipped", "queued") + + self.core.files.save() + pylink.release() return -- cgit v1.2.3 From a165fce9fdcba70158e3e980b2c0ecf13698c65c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 23 Dec 2014 22:54:26 +0100 Subject: [SkipRev] Typo --- module/plugins/hooks/SkipRev.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 2a971bb7c..1eaee0118 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -12,7 +12,7 @@ from module.plugins.Plugin import SkipDownload def _setup(self): self.pyfile.plugin._setup() if self.pyfile.hasStatus("skipped"): - raise SkipDownload(self.pyfile.self.statusname or self.pyfile.pluginname) + raise SkipDownload(self.pyfile.statusname or self.pyfile.pluginname) class SkipRev(Hook): -- cgit v1.2.3 From 3a7839e3c8f78c729adde099f071c31abf64ea1b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 24 Dec 2014 16:48:08 +0100 Subject: [SkipRev] Improve downloadFailed routine --- module/plugins/hooks/SkipRev.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/SkipRev.py') diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 1eaee0118..cc32c365e 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -18,7 +18,7 @@ def _setup(self): class SkipRev(Hook): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.20" + __version__ = "0.21" __config__ = [("tokeep", "int", "Number of rev files to keep for package (-1 to auto)", -1)] @@ -72,7 +72,7 @@ class SkipRev(Hook): tokeep = self.getConfig("tokeep") if tokeep: - saved = [True for link in self.core.api.getPackageData(pyfile.packageid).links \ + saved = [True for link in self.core.api.getPackageData(pyfile.package().id).links \ if link.name.endswith(".rev") and link.status in (0, 12)].count(True) if not saved or saved < tokeep: #: keep one rev at least in auto mode @@ -84,12 +84,17 @@ class SkipRev(Hook): def downloadFailed(self, pyfile): + #: Check if pyfile is still "failed", + # maybe might has been restarted in meantime + if pyfile.status != 8: + return + tokeep = self.getConfig("tokeep") if not tokeep: return - for link in self.core.api.getPackageData(pyfile.packageid).links: + for link in self.core.api.getPackageData(pyfile.package().id).links: if link.status is 4 and link.name.endswith(".rev"): pylink = self._pyfile(link) -- cgit v1.2.3