How to properly detect the underlying OS inside of XBMC python? - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: How to properly detect the underlying OS inside of XBMC python? (/showthread.php?tid=125005) |
How to properly detect the underlying OS inside of XBMC python? - bossanova808 - 2012-03-08 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: Code: LOCALSQUEEZESLAVEVERSION = 'squeezeslave-1.2-311' - giftie - 2012-03-08 Have you tried Code: sys.platform you probably will need to use a combination of sys.platform and the platform module. - bossanova808 - 2012-03-08 I am pretty sure I have actually. It's not having a Mac that makes this hard....but I think all the ones I have tried raise exceptions. Although maybe I have been confusing platform.platform and sys.platform.... - analogue - 2012-03-08 Most everything except for 32 bit vs 64 bit but you can narrow that down easily... https://github.com/analogue/mythbox/blob/master/resources/src/mythbox/platform.py#L31 - sphere - 2012-03-08 Or you can go with this code: https://github.com/dersphere/script.xbmc.debug.log/blob/Eden/resources/lib/gui.py#L68 No 32/64 bit detection in linux... - bossanova808 - 2012-03-09 Hey folks - thanks, those examples really helped and I think I've got it going on ok now. sys.platform is definitly the way to go, as platform.platform() raises exception (only on OSX) Next issue is the subprocess call.... http://forum.xbmc.org/showthread.php?tid=123613 - bossanova808 - 2012-03-09 Looks like my subprocess call may have been a permissions error (despite the wierd error message)...the call to os.system(chmod) - does NOT raise an exception on the Mac but apparently also does not do what it should grrr. I hate platform stuff, such a pain to work on and test! |