diff options
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/Extractor.py | 15 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 11 | ||||
-rw-r--r-- | module/plugins/internal/UnTar.py | 14 | ||||
-rw-r--r-- | module/plugins/internal/UnZip.py | 7 |
4 files changed, 30 insertions, 17 deletions
diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 8a16cdd38..a912843a1 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -23,7 +23,7 @@ class PasswordError(Exception): class Extractor(Plugin): __name__ = "Extractor" __type__ = "extractor" - __version__ = "0.42" + __version__ = "0.43" __status__ = "stable" __description__ = """Base extractor plugin""" @@ -104,7 +104,7 @@ class Extractor(Plugin): self.excludefiles = excludefiles self.priority = priority self.keepbroken = keepbroken - self.progress = lambda x: pyfile.setProgress(int(x)) + self.files = None self.init() @@ -119,11 +119,6 @@ class Extractor(Plugin): return encode(self.out) - def _log(self, level, plugintype, pluginname, messages): - messages = (self.__name__,) + messages - return self.pyfile.plugin._log(level, plugintype, self.pyfile.plugin.__name__, messages) - - def verify(self, password=None): """ Testing with Extractors built-in method @@ -156,3 +151,9 @@ class Extractor(Plugin): Return list of archive files """ raise NotImplementedError + + def progress(self, x): + """ + Set extraction progress + """ + return self.pyfile.setProgress(int(x)) diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 3b1d7b290..18416a4fe 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -12,7 +12,7 @@ from module.plugins.internal.misc import decode, encode, fsjoin, renice class UnRar(Extractor): __name__ = "UnRar" __type__ = "extractor" - __version__ = "1.31" + __version__ = "1.32" __status__ = "testing" __description__ = """RAR extractor plugin""" @@ -123,7 +123,7 @@ class UnRar(Extractor): break #: Reading a percentage sign -> set progress and restart if c == "%": - self.notifyprogress(int(s)) + self.pyfile.setProgress(int(s)) s = "" #: Not reading a digit -> therefore restart elif c not in string.digits: @@ -155,6 +155,8 @@ class UnRar(Extractor): if p.returncode: raise ArchiveError(_("Process return code: %d") % p.returncode) + return self.list(password) + def chunks(self): dir, name = os.path.split(self.filename) @@ -192,7 +194,8 @@ class UnRar(Extractor): for f in decode(out).splitlines(): result.add(fsjoin(self.dest, f.strip())) - return list(result) + self.files = list(result) + return self.files def call_cmd(self, command, *xargs, **kwargs): @@ -206,7 +209,7 @@ class UnRar(Extractor): args.append("-or") for word in self.excludefiles: - args.append("-x'%s'" % word.strip()) + args.append("-x%s" % word.strip()) #: Assume yes on all queries args.append("-y") diff --git a/module/plugins/internal/UnTar.py b/module/plugins/internal/UnTar.py index f2a140ca7..13a233634 100644 --- a/module/plugins/internal/UnTar.py +++ b/module/plugins/internal/UnTar.py @@ -12,7 +12,7 @@ from module.plugins.internal.misc import encode class UnTar(Extractor): __name__ = "UnTar" __type__ = "extractor" - __version__ = "0.01" + __version__ = "0.02" __status__ = "stable" __description__ = """TAR extractor plugin""" @@ -25,7 +25,10 @@ class UnTar(Extractor): @classmethod def isarchive(cls, filename): - return tarfile.is_tarfile(encode(filename)) + try: + return tarfile.is_tarfile(encode(filename)) + except: + return False @classmethod @@ -35,7 +38,8 @@ class UnTar(Extractor): def list(self, password=None): with tarfile.open(self.target) as t: - return t.getnames() + self.files = t.getnames() + return self.files def verify(self, password=None): @@ -53,11 +57,13 @@ class UnTar(Extractor): def extract(self, password=None): - self.verify() + self.verify(password) try: with tarfile.open(self.target, errorlevel=2) as t: t.extractall(self.dest) + self.files = t.getnames() + return self.files except tarfile.ExtractError, e: self.log_warning(e) diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index 50ab80da3..4a05ea155 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -12,7 +12,7 @@ from module.plugins.internal.misc import encode class UnZip(Extractor): __name__ = "UnZip" __type__ = "extractor" - __version__ = "1.21" + __version__ = "1.22" __status__ = "stable" __description__ = """ZIP extractor plugin""" @@ -36,7 +36,8 @@ class UnZip(Extractor): def list(self, password=None): with zipfile.ZipFile(self.target, 'r') as z: z.setpassword(password) - return z.namelist() + self.files = z.namelist() + return self.files def verify(self, password=None): @@ -63,6 +64,8 @@ class UnZip(Extractor): with zipfile.ZipFile(self.target, 'r') as z: z.setpassword(password) z.extractall(self.dest) + self.files = z.namelist() + return self.files except RuntimeError, e: raise ArchiveError(e) |