summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-03-01 22:41:08 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-03-01 22:41:08 +0100
commit3a9c167ceca27d57dbef927626fe853a3d0e30b2 (patch)
treed16cad2af7214c3b5ba619aab2bc2305e2822f74 /module/plugins/internal
parent[UpdateManager] Fix https://github.com/pyload/pyload/issues/1089 (diff)
downloadpyload-3a9c167ceca27d57dbef927626fe853a3d0e30b2.tar.xz
[Extractor] Use self.target
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Extractor.py2
-rw-r--r--module/plugins/internal/SevenZip.py14
-rw-r--r--module/plugins/internal/UnRar.py18
-rw-r--r--module/plugins/internal/UnZip.py7
4 files changed, 20 insertions, 21 deletions
diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py
index ee62ebcb7..bc8e67c6d 100644
--- a/module/plugins/internal/Extractor.py
+++ b/module/plugins/internal/Extractor.py
@@ -3,6 +3,7 @@
import os
from module.PyFile import PyFile
+from module.utils import fs_encode
class ArchiveError(Exception):
@@ -71,6 +72,7 @@ class Extractor:
fid=None):
""" Initialize extractor for specific file """
self.manager = manager
+ self.target = "'%s'" % fs_encode(filename)
self.filename = filename
self.out = out
self.fullpath = fullpath
diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py
index a3df52559..5280338dc 100644
--- a/module/plugins/internal/SevenZip.py
+++ b/module/plugins/internal/SevenZip.py
@@ -6,7 +6,7 @@ import re
from subprocess import Popen, PIPE
from module.plugins.internal.UnRar import ArchiveError, CRCError, PasswordError, UnRar, renice
-from module.utils import fs_encode, save_join
+from module.utils import save_join
class SevenZip(UnRar):
@@ -54,10 +54,8 @@ class SevenZip(UnRar):
def test(self, password):
- file = fs_encode(self.filename)
-
# 7z can't distinguish crc and pw error in test
- p = self.call_cmd("l", "-slt", file)
+ p = self.call_cmd("l", "-slt", self.target)
out, err = p.communicate()
if self.re_wrongpwd.search(out):
@@ -72,9 +70,7 @@ class SevenZip(UnRar):
def check(self, password):
- file = fs_encode(self.filename)
-
- p = self.call_cmd("l", "-slt", file)
+ p = self.call_cmd("l", "-slt", self.target)
out, err = p.communicate()
# check if output or error macthes the 'wrong password'-Regexp
@@ -92,7 +88,7 @@ class SevenZip(UnRar):
def extract(self, password=None):
command = "x" if self.fullpath else "e"
- p = self.call_cmd(command, '-o' + self.out, fs_encode(self.filename), password=password)
+ p = self.call_cmd(command, '-o' + self.out, self.target, password=password)
renice(p.pid, self.renice)
@@ -119,7 +115,7 @@ class SevenZip(UnRar):
def list(self, password=None):
command = "l" if self.fullpath else "l"
- p = self.call_cmd(command, fs_encode(self.filename), password=password)
+ p = self.call_cmd(command, self.target, password=password)
out, err = p.communicate()
if "Can not open" in err:
diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py
index eb969bb60..188fc88bb 100644
--- a/module/plugins/internal/UnRar.py
+++ b/module/plugins/internal/UnRar.py
@@ -8,7 +8,7 @@ from string import digits
from subprocess import Popen, PIPE
from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError
-from module.utils import decode, fs_encode, save_join
+from module.utils import fs_decode, save_join
def renice(pid, value):
@@ -56,6 +56,7 @@ class UnRar(Extractor):
out, err = p.communicate()
cls.__name__ = "RAR"
cls.REPAIR = True
+
except OSError:
cls.CMD = os.path.join(pypath, "UnRAR.exe")
p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE)
@@ -66,6 +67,7 @@ class UnRar(Extractor):
out, err = p.communicate()
cls.__name__ = "RAR"
cls.REPAIR = True
+
except OSError: #: fallback to unrar
p = Popen([cls.CMD], stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
@@ -87,7 +89,7 @@ class UnRar(Extractor):
def test(self, password):
- p = self.call_cmd("t", "-v", fs_encode(self.filename), password=password)
+ p = self.call_cmd("t", "-v", self.target, password=password)
self._progress(p)
err = p.stderr.read().strip()
@@ -99,7 +101,7 @@ class UnRar(Extractor):
def check(self, password):
- p = self.call_cmd("l", "-v", fs_encode(self.filename), password=password)
+ p = self.call_cmd("l", "-v", self.target, password=password)
out, err = p.communicate()
if self.re_wrongpwd.search(err):
@@ -115,7 +117,7 @@ class UnRar(Extractor):
def repair(self):
- p = self.call_cmd("rc", fs_encode(self.filename))
+ p = self.call_cmd("rc", self.target)
# communicate and retrieve stderr
self._progress(p)
@@ -147,7 +149,7 @@ class UnRar(Extractor):
def extract(self, password=None):
command = "x" if self.fullpath else "e"
- p = self.call_cmd(command, fs_encode(self.filename), self.out, password=password)
+ p = self.call_cmd(command, self.target, self.out, password=password)
renice(p.pid, self.renice)
@@ -187,7 +189,7 @@ class UnRar(Extractor):
def list(self, password=None):
command = "vb" if self.fullpath else "lb"
- p = self.call_cmd(command, "-v", fs_encode(self.filename), password=password)
+ p = self.call_cmd(command, "-v", self.target, password=password)
out, err = p.communicate()
if "Cannot open" in err:
@@ -199,12 +201,12 @@ class UnRar(Extractor):
result = set()
if not self.fullpath and self.VERSION.startswith('5'):
# NOTE: Unrar 5 always list full path
- for f in decode(out).splitlines():
+ for f in fs_decode(out).splitlines():
f = save_join(self.out, os.path.basename(f.strip()))
if os.path.isfile(f):
result.add(save_join(self.out, os.path.basename(f)))
else:
- for f in decode(out).splitlines():
+ for f in fs_decode(out).splitlines():
f = f.strip()
result.add(save_join(self.out, f))
diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py
index d95afbc70..dd57a54a7 100644
--- a/module/plugins/internal/UnZip.py
+++ b/module/plugins/internal/UnZip.py
@@ -7,7 +7,6 @@ import sys
import zipfile
from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, PasswordError
-from module.utils import fs_encode
class UnZip(Extractor):
@@ -29,7 +28,7 @@ class UnZip(Extractor):
def list(self, password=None):
- with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z:
+ with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z:
z.setpassword(password)
return z.namelist()
@@ -39,7 +38,7 @@ class UnZip(Extractor):
def test(self):
- with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z:
+ with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z:
badfile = z.testzip()
if badfile:
@@ -50,7 +49,7 @@ class UnZip(Extractor):
def extract(self, password=None):
try:
- with zipfile.ZipFile(fs_encode(self.filename), 'r', allowZip64=True) as z:
+ with zipfile.ZipFile(self.target, 'r', allowZip64=True) as z:
z.setpassword(password)
badfile = z.testzip()