From 33ad4c22c7f8edc8062c13731da2bfc6a0644e6d Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 30 Jun 2014 21:58:19 +0200 Subject: [PATCH] Try make unrar executable for user --- libs/unrar2/unix.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/unrar2/unix.py b/libs/unrar2/unix.py index a37b6df6..ce2d6a7e 100644 --- a/libs/unrar2/unix.py +++ b/libs/unrar2/unix.py @@ -21,7 +21,8 @@ # SOFTWARE. # Unix version uses unrar command line executable - +import platform +import stat import subprocess import gc import os @@ -37,11 +38,19 @@ class UnpackerNotInstalled(Exception): pass rar_executable_cached = None rar_executable_version = None +osx_unrar = os.path.join(os.path.dirname(__file__), 'unrar') +if os.path.isfile(osx_unrar) and 'darwin' in platform.platform().lower(): + try: + st = os.stat(osx_unrar) + os.chmod(osx_unrar, st.st_mode | stat.S_IEXEC) + except: + pass + def call_unrar(params): "Calls rar/unrar command line executable, returns stdout pipe" global rar_executable_cached if rar_executable_cached is None: - for command in ('unrar', 'rar', os.path.join(os.path.dirname(__file__), 'unrar')): + for command in ('unrar', 'rar', osx_unrar): try: subprocess.Popen([command], stdout = subprocess.PIPE) rar_executable_cached = command