From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hooks/UnSkipOnFail.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index af6039ecd..f25482b79 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: hgg """ from os.path import basename @@ -26,10 +24,14 @@ from module.PyFile import PyFile class UnSkipOnFail(Hook): __name__ = 'UnSkipOnFail' __version__ = '0.01' - __description__ = """When a download fails, restart skipped duplicates""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", True)] + + __description__ = """When a download fails, restart skipped duplicates""" __author_name__ = "hagg" - __author_mail__ = "" + __author_mail__ = None + def downloadFailed(self, pyfile): pyfile_name = basename(pyfile.name) -- cgit v1.2.3 From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- module/plugins/hooks/UnSkipOnFail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f25482b79..d40854e99 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -22,8 +22,8 @@ from module.PyFile import PyFile class UnSkipOnFail(Hook): - __name__ = 'UnSkipOnFail' - __version__ = '0.01' + __name__ = "UnSkipOnFail" + __version__ = "0.01" __type__ = "hook" __config__ = [("activated", "bool", "Activated", True)] -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hooks/UnSkipOnFail.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index d40854e99..f25c5e2b4 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -1,30 +1,16 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from os.path import basename -from module.utils import fs_encode -from module.plugins.Hook import Hook from module.PyFile import PyFile +from module.plugins.Hook import Hook +from module.utils import fs_encode class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" - __version__ = "0.01" __type__ = "hook" + __version__ = "0.01" __config__ = [("activated", "bool", "Activated", True)] -- cgit v1.2.3 From 0d220d634e512d89bda540f91c643b361c82ea8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Sep 2014 01:38:32 +0200 Subject: Logging string cosmetics --- module/plugins/hooks/UnSkipOnFail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f25c5e2b4..685c9573d 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -22,14 +22,14 @@ class UnSkipOnFail(Hook): def downloadFailed(self, pyfile): pyfile_name = basename(pyfile.name) pid = pyfile.package().id - msg = 'look for skipped duplicates for %s (pid:%s)...' + msg = _('look for skipped duplicates for %s (pid:%s)') self.logInfo(msg % (pyfile_name, pid)) dups = self.findDuplicates(pyfile) for link in dups: # check if link is "skipped"(=4) if link.status == 4: lpid = link.packageID - self.logInfo('restart "%s" (pid:%s)...' % (pyfile_name, lpid)) + self.logInfo(_('restart "%s" (pid:%s)') % (pyfile_name, lpid)) self.setLinkStatus(link, "queued") def findDuplicates(self, pyfile): -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/hooks/UnSkipOnFail.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 685c9573d..983eb21fa 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -15,8 +15,7 @@ class UnSkipOnFail(Hook): __config__ = [("activated", "bool", "Activated", True)] __description__ = """When a download fails, restart skipped duplicates""" - __author_name__ = "hagg" - __author_mail__ = None + __authors__ = [("hagg", None)] def downloadFailed(self, pyfile): -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/hooks/UnSkipOnFail.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 983eb21fa..f29383b32 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -15,6 +15,7 @@ class UnSkipOnFail(Hook): __config__ = [("activated", "bool", "Activated", True)] __description__ = """When a download fails, restart skipped duplicates""" + __license__ = "GPLv3" __authors__ = [("hagg", None)] -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/hooks/UnSkipOnFail.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f29383b32..e3c0f6af9 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -32,6 +32,7 @@ class UnSkipOnFail(Hook): self.logInfo(_('restart "%s" (pid:%s)') % (pyfile_name, lpid)) self.setLinkStatus(link, "queued") + def findDuplicates(self, pyfile): """ Search all packages for duplicate links to "pyfile". Duplicates are links that would overwrite "pyfile". @@ -61,6 +62,7 @@ class UnSkipOnFail(Hook): dups.append(link) return dups + def setLinkStatus(self, link, new_status): """ Change status of "link" to "new_status". "link" has to be a valid FileData object, -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/hooks/UnSkipOnFail.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index e3c0f6af9..f97d12431 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -8,15 +8,15 @@ from module.utils import fs_encode class UnSkipOnFail(Hook): - __name__ = "UnSkipOnFail" - __type__ = "hook" + __name__ = "UnSkipOnFail" + __type__ = "hook" __version__ = "0.01" __config__ = [("activated", "bool", "Activated", True)] __description__ = """When a download fails, restart skipped duplicates""" - __license__ = "GPLv3" - __authors__ = [("hagg", None)] + __license__ = "GPLv3" + __authors__ = [("hagg", None)] def downloadFailed(self, pyfile): -- 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/UnSkipOnFail.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index f97d12431..d3baccfc2 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -10,7 +10,7 @@ from module.utils import fs_encode class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.01" + __version__ = "0.02" __config__ = [("activated", "bool", "Activated", True)] @@ -19,6 +19,11 @@ class UnSkipOnFail(Hook): __authors__ = [("hagg", None)] + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + def downloadFailed(self, pyfile): pyfile_name = basename(pyfile.name) pid = pyfile.package().id -- cgit v1.2.3 From 429f8b54b11b1df9d99aa8f3fe222e47d98a5faf Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 24 Dec 2014 16:49:01 +0100 Subject: [UnSkipOnFail] Rewritten --- module/plugins/hooks/UnSkipOnFail.py | 127 ++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 62 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index d3baccfc2..87c21dda7 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -1,22 +1,19 @@ # -*- coding: utf-8 -*- -from os.path import basename - from module.PyFile import PyFile from module.plugins.Hook import Hook -from module.utils import fs_encode class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.02" + __version__ = "0.03" __config__ = [("activated", "bool", "Activated", True)] - __description__ = """When a download fails, restart skipped duplicates""" + __description__ = """Queue skipped duplicates""" __license__ = "GPLv3" - __authors__ = [("hagg", None)] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] #@TODO: Remove in 0.4.10 @@ -25,68 +22,74 @@ class UnSkipOnFail(Hook): def downloadFailed(self, pyfile): - pyfile_name = basename(pyfile.name) - pid = pyfile.package().id - msg = _('look for skipped duplicates for %s (pid:%s)') - self.logInfo(msg % (pyfile_name, pid)) - dups = self.findDuplicates(pyfile) - for link in dups: - # check if link is "skipped"(=4) - if link.status == 4: - lpid = link.packageID - self.logInfo(_('restart "%s" (pid:%s)') % (pyfile_name, lpid)) - self.setLinkStatus(link, "queued") - - - def findDuplicates(self, pyfile): + #: Check if pyfile is still "failed", + # maybe might has been restarted in meantime + if pyfile.status != 8: + return + + msg = _("Looking for skipped duplicates of: %s (pid:%s)") + self.logInfo(msg % (pyfile.name, pyfile.package().id)) + + dup = self.findDuplicate(pyfile) + if dup: + self.logInfo(_("Queue found duplicate: %s (pid:%s)") % (dup.name, dup.packageID)) + + #: Change status of "link" to "new_status". + # "link" has to be a valid FileData object, + # "new_status" has to be a valid status name + # (i.e. "queued" for this Plugin) + # It creates a temporary PyFile object using + # "link" data, changes its status, and tells + # the core.files-manager to save its data. + pylink = _pyfile(link) + + pylink.setCustomStatus("UnSkipOnFail", "queued") + + self.core.files.save() + pylink.release() + + else: + self.logInfo(_("No duplicates found")) + + + def findDuplicate(self, pyfile): """ Search all packages for duplicate links to "pyfile". Duplicates are links that would overwrite "pyfile". To test on duplicity the package-folder and link-name - of twolinks are compared (basename(link.name)). + of twolinks are compared (link.name). So this method returns a list of all links with equal package-folders and filenames as "pyfile", but except the data for "pyfile" iotselöf. It does MOT check the link's status. """ - dups = [] - pyfile_name = fs_encode(basename(pyfile.name)) - # get packages (w/o files, as most file data is useless here) - queue = self.core.api.getQueue() + queue = self.api.getQueue() #: get packages (w/o files, as most file data is useless here) + for package in queue: - # check if package-folder equals pyfile's package folder - if fs_encode(package.folder) == fs_encode(pyfile.package().folder): - # now get packaged data w/ files/links - pdata = self.core.api.getPackageData(package.pid) - if pdata.links: - for link in pdata.links: - link_name = fs_encode(basename(link.name)) - # check if link name collides with pdata's name - if link_name == pyfile_name: - # at last check if it is not pyfile itself - if link.fid != pyfile.id: - dups.append(link) - return dups - - - def setLinkStatus(self, link, new_status): - """ Change status of "link" to "new_status". - "link" has to be a valid FileData object, - "new_status" has to be a valid status name - (i.e. "queued" for this Plugin) - It creates a temporary PyFile object using - "link" data, changes its status, and tells - the core.files-manager to save its data. - """ - pyfile = PyFile(self.core.files, - link.fid, - link.url, - link.name, - link.size, - link.status, - link.error, - link.plugin, - link.packageID, - link.order) - pyfile.setStatus(new_status) - self.core.files.save() - pyfile.release() + #: check if package-folder equals pyfile's package folder + if package.folder != pyfile.package().folder: + continue + + #: now get packaged data w/ files/links + pdata = self.api.getPackageData(package.pid) + for link in pdata.links: + #: check if link is "skipped" + if link.status != 4: + continue + + #: check if link name collides with pdata's name + #: AND at last check if it is not pyfile itself + if link.name == pyfile.name and link.fid != pyfile.id: + return link + + + 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) -- cgit v1.2.3 From 22285c54c80b59ac17dd6a74dcb2044729258f43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 24 Dec 2014 16:50:22 +0100 Subject: [UnSkipOnFail] Rewritten (2) --- module/plugins/hooks/UnSkipOnFail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 87c21dda7..fad29b17b 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -11,7 +11,7 @@ class UnSkipOnFail(Hook): __config__ = [("activated", "bool", "Activated", True)] - __description__ = """Queue skipped duplicates""" + __description__ = """Queue skipped duplicates when download fails""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From 8930bf1dc4e3915c46b413d5d61868dabf7d24d3 Mon Sep 17 00:00:00 2001 From: pbr85at Date: Thu, 25 Dec 2014 12:46:13 +0100 Subject: Update UnSkipOnFail.py indent error --- module/plugins/hooks/UnSkipOnFail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index fad29b17b..37f193f5d 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -52,7 +52,7 @@ class UnSkipOnFail(Hook): self.logInfo(_("No duplicates found")) - def findDuplicate(self, pyfile): + def findDuplicate(self, pyfile): """ Search all packages for duplicate links to "pyfile". Duplicates are links that would overwrite "pyfile". To test on duplicity the package-folder and link-name -- cgit v1.2.3 From 37c4fdbe85bd193ec69e222330f05b7adf742145 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 25 Dec 2014 16:08:32 +0100 Subject: [UnSkipOnFail] Bump up version --- module/plugins/hooks/UnSkipOnFail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 37f193f5d..88557e831 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -7,7 +7,7 @@ from module.plugins.Hook import Hook class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.03" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated", True)] -- cgit v1.2.3 From 60c4c83ed84f5bf7f638f99d21e74af314935280 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 26 Dec 2014 04:20:27 +0100 Subject: [UnSkipOnFail] Fixup --- module/plugins/hooks/UnSkipOnFail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/UnSkipOnFail.py') diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 88557e831..1becb937a 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -7,7 +7,7 @@ from module.plugins.Hook import Hook class UnSkipOnFail(Hook): __name__ = "UnSkipOnFail" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("activated", "bool", "Activated", True)] @@ -62,7 +62,7 @@ class UnSkipOnFail(Hook): the data for "pyfile" iotselöf. It does MOT check the link's status. """ - queue = self.api.getQueue() #: get packages (w/o files, as most file data is useless here) + queue = self.core.api.getQueue() #: get packages (w/o files, as most file data is useless here) for package in queue: #: check if package-folder equals pyfile's package folder @@ -70,7 +70,7 @@ class UnSkipOnFail(Hook): continue #: now get packaged data w/ files/links - pdata = self.api.getPackageData(package.pid) + pdata = self.core.api.getPackageData(package.pid) for link in pdata.links: #: check if link is "skipped" if link.status != 4: -- cgit v1.2.3