2012-03-08, 04:21
This should in principle be easy enough, but it's not working as expected for me.
Some background - I need to know which OS my addon is running on as it supplies and calls an external binary.
I need to distinguish OSX, Windows, and then Linux 32 and Linux 64.
I have tried both platform.platform() and platform.system() and they seem to work on Windows but raise an exception on OSX.
Has anyone got a good XBMC Ok way of doing this? I don't have a Mac very handy to try this out unfortunately.
ANY HELP MUCH APPRECIATED!!
My code is currently:
Some background - I need to know which OS my addon is running on as it supplies and calls an external binary.
I need to distinguish OSX, Windows, and then Linux 32 and Linux 64.
I have tried both platform.platform() and platform.system() and they seem to work on Windows but raise an exception on OSX.
Has anyone got a good XBMC Ok way of doing this? I don't have a Mac very handy to try this out unfortunately.
ANY HELP MUCH APPRECIATED!!
My code is currently:
Code:
LOCALSQUEEZESLAVEVERSION = 'squeezeslave-1.2-311'
BINWIN = xbmc.translatePath(os.path.join( BIN_PATH, LOCALSQUEEZESLAVEVERSION + "-win") + "//squeezeslave.exe")
BINOSX = xbmc.translatePath(os.path.join( BIN_PATH, LOCALSQUEEZESLAVEVERSION + "-osx") + "//squeezeslave")
BINLIN32 = xbmc.translatePath(os.path.join( BIN_PATH, LOCALSQUEEZESLAVEVERSION + "-lnx26") + "//squeezeslave")
BINLIN64 = xbmc.translatePath(os.path.join( BIN_PATH, LOCALSQUEEZESLAVEVERSION + "-lnx26") + "//squeezeslave-i64")
#need to work out what system we're on
SYSTEM=""
try:
#will return Windows or Darwin
SYSTEM = platform.platform()
except:
#otherwise we assume some linux 2.6+ flavour...
SYSTEM = "Linux"
#32 or 64 bit?
is_64bits = sys.maxsize > 2**32
#choose the right executable
if SYSTEM.startswith("Windows"):
EXE = [BINWIN]
elif SYSTEM.startswith("Darwin"):
EXE = [BINOSX]
else:
if is_64bits:
EXE = [BINLIN64]
else:
EXE = [BINLIN32]
#chmod +X the exe file...
if SYSTEM=="Darwin" or SYSTEM=="Linux":
try:
#attempt to make the binary executable - this never works really...
#it's really about triggering the messages in the except clause below...
os.system("chmod a+x " + EXE[0])
xbmc.log(__addonname__ + "-" + __version__ +": ### chmod +x the Squeezeslave binaries - success")
except:
xbmc.log(__addonname__ + __version__ +": chmod +x the Squeezeslave binaries - failure -> You must do this manually!!")
#Logger.notify("Failed to chmod +x the binaries" "Please do so manually - most likely a user permissions error", 10000)