diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-21 22:55:54 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-07-21 22:55:54 +0200 |
commit | c2091ebec0ce394ec847f82db9bbaddc150d5fca (patch) | |
tree | 04e2515544d3d47242c991fe540954c0d0080164 /module/plugins | |
parent | New Captcha skeleton (diff) | |
download | pyload-c2091ebec0ce394ec847f82db9bbaddc150d5fca.tar.xz |
[Extractor] is_usable -> find
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/Extractor.py | 6 | ||||
-rw-r--r-- | module/plugins/internal/SevenZip.py | 24 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 45 | ||||
-rw-r--r-- | module/plugins/internal/UnZip.py | 4 |
5 files changed, 45 insertions, 38 deletions
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index 8a52fed55..6f353f538 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -112,7 +112,7 @@ class ArchiveQueue(object): class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" - __version__ = "1.46" + __version__ = "1.47" __status__ = "stable" __config__ = [("activated" , "bool" , "Activated" , True ), @@ -162,7 +162,7 @@ class ExtractArchive(Addon): try: module = self.pyload.pluginManager.loadModule("internal", p) klass = getattr(module, p) - if klass.is_usable(): + if klass.find(): self.extractors.append(klass) if klass.REPAIR: self.repair = self.get_config('repair') diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index e1fb2332d..3d2859f54 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -22,7 +22,7 @@ class PasswordError(Exception): class Extractor(Plugin): __name__ = "Extractor" __type__ = "extractor" - __version__ = "0.25" + __version__ = "0.26" __status__ = "stable" __description__ = """Base extractor plugin""" @@ -48,12 +48,12 @@ class Extractor(Plugin): @classmethod - def is_usable(cls): + def find(cls): """ Check if system statisfy dependencies :return: boolean """ - return None + pass @classmethod 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): diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index a880ab320..03b19bcf9 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -22,7 +22,7 @@ def renice(pid, value): class UnRar(Extractor): __name__ = "UnRar" - __version__ = "1.21" + __version__ = "1.22" __status__ = "stable" __description__ = """Rar extractor plugin""" @@ -49,34 +49,37 @@ class UnRar(Extractor): @classmethod - def is_usable(cls): - if os.name == "nt": - try: + def find(cls): + try: + if os.name == "nt": cls.CMD = os.path.join(pypath, "RAR.exe") - p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - cls.__name__ = "RAR" - cls.REPAIR = True + else: + cls.CMD = "rar" - except OSError: - cls.CMD = os.path.join(pypath, "UnRAR.exe") - p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - else: + p = subprocess.Popen([cls.CMD], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = p.communicate() + cls.__name__ = "RAR" + cls.REPAIR = True + + except OSError: try: - p = subprocess.Popen(["rar"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = p.communicate() - cls.__name__ = "RAR" - cls.REPAIR = True + if os.name == "nt": + cls.CMD = os.path.join(pypath, "UnRAR.exe") + else: + cls.CMD = "unrar" - except OSError: #: Fallback to unrar 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 - return True + else: + return True + + finally: + m = cls.re_version.search(out) + cls.VERSION = m.group(1) if m else '(version unknown)' @classmethod diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index 1088f571a..ef2b2b56d 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -12,7 +12,7 @@ from module.utils import fs_encode class UnZip(Extractor): __name__ = "UnZip" - __version__ = "1.13" + __version__ = "1.14" __status__ = "stable" __description__ = """Zip extractor plugin""" @@ -25,7 +25,7 @@ class UnZip(Extractor): @classmethod - def is_usable(cls): + def find(cls): return sys.version_info[:2] >= (2, 6) |