diff options
Diffstat (limited to 'module/plugins/internal/UnRar.py')
-rw-r--r-- | module/plugins/internal/UnRar.py | 45 |
1 files changed, 24 insertions, 21 deletions
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 |