diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-02-22 17:06:38 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-02-22 17:06:38 +0100 |
commit | 38995b29744a0a4101a3b26c53f5f0a60b30bda4 (patch) | |
tree | 0a6d7d06bb4cddead1ac7416c19331db917b38e4 /pyload/plugin/extractor/SevenZip.py | |
parent | Tiny code cosmetics (diff) | |
parent | [HotFolder] Fixup (thx zapp-brannigan) (diff) | |
download | pyload-38995b29744a0a4101a3b26c53f5f0a60b30bda4.tar.xz |
Merge branch 'stable' into 0.4.10
Conflicts:
module/plugins/container/LinkList.py
module/plugins/container/TXT.py
module/plugins/hoster/HundredEightyUploadCom.py
pyload/plugin/Extractor.py
pyload/plugin/addon/ClickAndLoad.py
pyload/plugin/addon/ExtractArchive.py
pyload/plugin/addon/HotFolder.py
pyload/plugin/container/TXT.py
pyload/plugin/extractor/SevenZip.py
pyload/plugin/extractor/UnRar.py
pyload/plugin/extractor/UnZip.py
pyload/plugin/hook/XFileSharingPro.py
pyload/plugin/hoster/ZippyshareCom.py
Diffstat (limited to 'pyload/plugin/extractor/SevenZip.py')
-rw-r--r-- | pyload/plugin/extractor/SevenZip.py | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/pyload/plugin/extractor/SevenZip.py b/pyload/plugin/extractor/SevenZip.py index 74eb4c855..1d7d57886 100644 --- a/pyload/plugin/extractor/SevenZip.py +++ b/pyload/plugin/extractor/SevenZip.py @@ -12,7 +12,7 @@ from pyload.utils import fs_encode, safe_join class SevenZip(UnRar): __name = "SevenZip" __type = "extractor" - __version = "0.08" + __version = "0.09" __description = """7-Zip extractor plugin""" __license = "GPLv3" @@ -33,9 +33,9 @@ class SevenZip(UnRar): #@NOTE: there are some more uncovered 7z formats re_filelist = re.compile(r'([\d\:]+)\s+([\d\:]+)\s+([\w\.]+)\s+(\d+)\s+(\d+)\s+(.+)') - re_wrongpwd = re.compile(r'(Can not open encrypted archive|Wrong password)', re.I) - re_wrongcrc = re.compile(r'Encrypted\s+\=\s+\+', re.I) - re_version = re.compile(r'7-Zip\s(?:\[64\]\s)?(\d+\.\d+)', re.I) + re_wrongpwd = re.compile(r'(Can not open encrypted archive|Wrong password|Encrypted\s+\=\s+\+)', re.I) + re_wrongcrc = re.compile(r'CRC Failed|Can not open file', re.I) + re_version = re.compile(r'7-Zip\s(?:\[64\]\s)?(\d+\.\d+)', re.I) @classmethod @@ -53,36 +53,38 @@ class SevenZip(UnRar): return True - def check(self): + def test(self, password): file = fs_encode(self.filename) - p = self.call_cmd("t", file) + # 7z can't distinguish crc and pw error in test + p = self.call_cmd("l", "-slt", file) out, err = p.communicate() - if p.returncode > 1: + if self.re_wrongpwd.search(out): + raise PasswordError + + if self.re_wrongpwd.search(err): + raise PasswordError + + if self.re_wrongcrc.search(err): raise CRCError(err) + + + def check(self, password): + file = fs_encode(self.filename) + p = self.call_cmd("l", "-slt", file) out, err = p.communicate() - if p.returncode > 1: - raise ArchiveError(_("Process return code: %d") % p.returncode) - # check if output or error macthes the 'wrong password'-Regexp if self.re_wrongpwd.search(out): raise PasswordError - # check if output matches 'Encrypted = +' if self.re_wrongcrc.search(out): raise CRCError(_("Header protected")) - def isPassword(self, password): - p = self.call_cmd("l", fs_encode(self.filename), password=password) - p.communicate() - return p.returncode == 0 - - def repair(self): return False @@ -143,7 +145,7 @@ class SevenZip(UnRar): #set a password if "password" in kwargs and kwargs["password"]: - args.append("-p'%s'" % kwargs["password"]) + args.append("-p%s" % kwargs["password"]) else: args.append("-p-") |