From 5a139055ae658d3a05cbb658cbd66aeae0d01db5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 21:06:10 +0200 Subject: Spare code cosmetics --- module/plugins/internal/SevenZip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 624f6c939..cad4cfa1c 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -5,7 +5,7 @@ import re import subprocess from module.plugins.internal.UnRar import ArchiveError, CRCError, PasswordError, UnRar, renice -from module.utils import fs_encode, save_join +from module.utils import fs_encode, save_join as fs_join class SevenZip(UnRar): @@ -126,7 +126,7 @@ class SevenZip(UnRar): result = set() for groups in self.re_filelist.findall(out): f = groups[-1].strip() - result.add(save_join(self.out, f)) + result.add(fs_join(self.out, f)) return list(result) -- cgit v1.2.3 From 20b6a2ec022202b0efb6cb69415239fb8f4d1445 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:59:20 +0200 Subject: Spare code cosmetics (2) --- module/plugins/internal/SevenZip.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index cad4cfa1c..7a79c278c 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -53,7 +53,7 @@ class SevenZip(UnRar): def verify(self, password): - # 7z can't distinguish crc and pw error in test + #: 7z can't distinguish crc and pw error in test p = self.call_cmd("l", "-slt", fs_encode(self.filename)) out, err = p.communicate() @@ -72,7 +72,7 @@ class SevenZip(UnRar): p = self.call_cmd("l", "-slt", fs_encode(self.filename)) out, err = p.communicate() - # check if output or error macthes the 'wrong password'-Regexp + #: check if output or error macthes the 'wrong password'-Regexp if self.re_wrongpwd.search(out): raise PasswordError @@ -91,7 +91,7 @@ class SevenZip(UnRar): renice(p.pid, self.renice) - # communicate and retrieve stderr + #: communicate and retrieve stderr self._progress(p) err = p.stderr.read().strip() -- cgit v1.2.3 From 9305859b64a2f0aef3f27fb7e5b75caa0cb836a6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 19:24:49 +0200 Subject: Spare code cosmetics (3) --- module/plugins/internal/SevenZip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 7a79c278c..147ac6bd4 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -139,8 +139,8 @@ class SevenZip(UnRar): args.append("-y") #set a password - if "password" in kwargs and kwargs["password"]: - args.append("-p%s" % kwargs["password"]) + if "password" in kwargs and kwargs['password']: + args.append("-p%s" % kwargs['password']) else: args.append("-p-") -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/internal/SevenZip.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 147ac6bd4..86ff5156e 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join as fs_join class SevenZip(UnRar): __name__ = "SevenZip" - __version__ = "0.11" + __version__ = "0.12" __description__ = """7-Zip extractor plugin""" __license__ = "GPLv3" @@ -37,7 +37,7 @@ class SevenZip(UnRar): @classmethod - def isUsable(cls): + def is_usable(cls): if os.name == "nt": cls.CMD = os.path.join(pypath, "7z.exe") p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -134,11 +134,11 @@ class SevenZip(UnRar): def call_cmd(self, command, *xargs, **kwargs): args = [] - #overwrite flag + # overwrite flag if self.overwrite: args.append("-y") - #set a password + # set a password if "password" in kwargs and kwargs['password']: args.append("-p%s" % kwargs['password']) else: -- cgit v1.2.3 From d2e2b127651a5a44b56337eb6d9ca246c97a208a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Jul 2015 03:03:26 +0200 Subject: Spare fixes and code cosmetics --- module/plugins/internal/SevenZip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 86ff5156e..d067468dd 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -147,7 +147,7 @@ class SevenZip(UnRar): #@NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue call = [self.CMD, command] + args + list(xargs) - self.manager.logDebug(" ".join(call)) + self.manager.log_debug(" ".join(call)) p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return p -- cgit v1.2.3 From dad722ac7255640e7e0541c4094a4d2e4de79cd3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 00:05:58 +0200 Subject: Code cosmetics (2) --- module/plugins/internal/SevenZip.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index d067468dd..c76ef43e2 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -72,7 +72,7 @@ class SevenZip(UnRar): p = self.call_cmd("l", "-slt", fs_encode(self.filename)) out, err = p.communicate() - #: check if output or error macthes the 'wrong password'-Regexp + #: Check if output or error macthes the 'wrong password'-Regexp if self.re_wrongpwd.search(out): raise PasswordError @@ -91,7 +91,7 @@ class SevenZip(UnRar): renice(p.pid, self.renice) - #: communicate and retrieve stderr + #: Communicate and retrieve stderr self._progress(p) err = p.stderr.read().strip() @@ -102,7 +102,7 @@ class SevenZip(UnRar): elif self.re_wrongcrc.search(err): raise CRCError(err) - else: #: raise error if anything is on stderr + else: #: Raise error if anything is on stderr raise ArchiveError(err) if p.returncode > 1: @@ -134,11 +134,11 @@ class SevenZip(UnRar): def call_cmd(self, command, *xargs, **kwargs): args = [] - # overwrite flag + #: Overwrite flag if self.overwrite: args.append("-y") - # set a password + #: Set a password if "password" in kwargs and kwargs['password']: args.append("-p%s" % kwargs['password']) else: -- cgit v1.2.3 From 56389e28ba5d2f5658278bc7f486d73be747f135 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 11:44:49 +0200 Subject: Rename self.core to self.pyload (plugins only) --- module/plugins/internal/SevenZip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index c76ef43e2..395025bc1 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -147,7 +147,7 @@ class SevenZip(UnRar): #@NOTE: return codes are not reliable, some kind of threading, cleanup whatever issue call = [self.CMD, command] + args + list(xargs) - self.manager.log_debug(" ".join(call)) + self.log_debug(" ".join(call)) p = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return p -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/internal/SevenZip.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 395025bc1..dc0d765cf 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -11,6 +11,7 @@ from module.utils import fs_encode, save_join as fs_join class SevenZip(UnRar): __name__ = "SevenZip" __version__ = "0.12" + __status__ = "stable" __description__ = """7-Zip extractor plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From c2091ebec0ce394ec847f82db9bbaddc150d5fca Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 21 Jul 2015 22:55:54 +0200 Subject: [Extractor] is_usable -> find --- module/plugins/internal/SevenZip.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index dc0d765cf..f2194157c 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join as fs_join class SevenZip(UnRar): __name__ = "SevenZip" - __version__ = "0.12" + __version__ = "0.13" __status__ = "stable" __description__ = """7-Zip extractor plugin""" @@ -38,19 +38,23 @@ class SevenZip(UnRar): @classmethod - def is_usable(cls): - if os.name == "nt": - cls.CMD = os.path.join(pypath, "7z.exe") - p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - else: + def find(cls): + try: + if os.name == "nt": + cls.CMD = os.path.join(pypath, "7z.exe") + p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() - m = cls.re_version.search(out) - cls.VERSION = m.group(1) if m else '(version unknown)' + except OSError: + return False + + else: + return True - return True + finally: + m = cls.re_version.search(out) + cls.VERSION = m.group(1) if m else '(version unknown)' def verify(self, password): -- cgit v1.2.3 From 94d017cd2a5c1f194960827a8c7e46afc3682008 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 06:55:49 +0200 Subject: Hotfixes (2) --- module/plugins/internal/SevenZip.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index f2194157c..dde12d17e 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -11,7 +11,7 @@ from module.utils import fs_encode, save_join as fs_join class SevenZip(UnRar): __name__ = "SevenZip" __version__ = "0.13" - __status__ = "stable" + __status__ = "testing" __description__ = """7-Zip extractor plugin""" __license__ = "GPLv3" @@ -40,7 +40,7 @@ class SevenZip(UnRar): @classmethod def find(cls): try: - if os.name == "nt": + if os.name is "nt": cls.CMD = os.path.join(pypath, "7z.exe") p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -- cgit v1.2.3 From 761ca5c66e07559925ebbdbc6531f9ca658b12ce Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 16:11:58 +0200 Subject: Code cosmetics --- module/plugins/internal/SevenZip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index dde12d17e..a5ccf2a26 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -40,7 +40,7 @@ class SevenZip(UnRar): @classmethod def find(cls): try: - if os.name is "nt": + if os.name == "nt": cls.CMD = os.path.join(pypath, "7z.exe") p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) -- cgit v1.2.3 From 5a2781c923ecd13f3e671366fa6fa311d92d8547 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 29 Jul 2015 08:21:04 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1586 --- module/plugins/internal/SevenZip.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal/SevenZip.py') diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index a5ccf2a26..5811c28de 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -10,7 +10,7 @@ from module.utils import fs_encode, save_join as fs_join class SevenZip(UnRar): __name__ = "SevenZip" - __version__ = "0.13" + __version__ = "0.14" __status__ = "testing" __description__ = """7-Zip extractor plugin""" @@ -19,9 +19,7 @@ class SevenZip(UnRar): ("Walter Purcaro", "vuolter@gmail.com")] - CMD = "7z" - VERSION = "" - + CMD = "7z" EXTENSIONS = [".7z", ".xz", ".zip", ".gz", ".gzip", ".tgz", ".bz2", ".bzip2", ".tbz2", ".tbz", ".tar", ".wim", ".swm", ".lzma", ".rar", ".cab", ".arj", ".z", ".taz", ".cpio", ".rpm", ".deb", ".lzh", ".lha", @@ -50,11 +48,11 @@ class SevenZip(UnRar): return False else: - return True - - finally: m = cls.re_version.search(out) - cls.VERSION = m.group(1) if m else '(version unknown)' + if m is not None: + cls.VERSION = m.group(1) + + return True def verify(self, password): -- cgit v1.2.3