Try make unrar executable for user

This commit is contained in:
Ruud
2014-06-30 21:58:19 +02:00
parent 265f90fe69
commit 33ad4c22c7
+11 -2
View File
@@ -21,7 +21,8 @@
# SOFTWARE. # SOFTWARE.
# Unix version uses unrar command line executable # Unix version uses unrar command line executable
import platform
import stat
import subprocess import subprocess
import gc import gc
import os import os
@@ -37,11 +38,19 @@ class UnpackerNotInstalled(Exception): pass
rar_executable_cached = None rar_executable_cached = None
rar_executable_version = 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): def call_unrar(params):
"Calls rar/unrar command line executable, returns stdout pipe" "Calls rar/unrar command line executable, returns stdout pipe"
global rar_executable_cached global rar_executable_cached
if rar_executable_cached is None: 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: try:
subprocess.Popen([command], stdout = subprocess.PIPE) subprocess.Popen([command], stdout = subprocess.PIPE)
rar_executable_cached = command rar_executable_cached = command