Platform/OS detection
#1
Is there a python function/variable to retrieve which platform/OS (XBOX, Win, Mac, Linux) a script or plugin is running on?

Thanks.

Rodejo
Reply
#2
rodejo16 Wrote:Is there a python function/variable to retrieve which platform/OS (XBOX, Win, Mac, Linux) a script or plugin is running on?

Thanks.

Rodejo

Here an way you can do it (I am not the creator of this function, Frostbox is):
- The function
Code:
import xbmc
def get_system_platform():
    """
    get platform on which xbmc run
    """
    platform = "unknown"
    if xbmc.getCondVisibility( "system.platform.linux" ):
        platform = "linux"
    elif xbmc.getCondVisibility( "system.platform.xbox" ):
        platform = "xbox"
    elif xbmc.getCondVisibility( "system.platform.windows" ):
        platform = "windows"
    elif xbmc.getCondVisibility( "system.platform.osx" ):
        platform = "osx"
    print "Platform: %s"%platform
    return platform

And a example to use it:
Code:
if get_system_platform() == "osx":
    print "Platform is MAC OSX"

I hope it helps
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#3
Isn't there a function in the os or sys modules that give you this?

EDIT: os.environ.get("OS")
Reply
#4
I'm not near an xbox to test or play around with this, but nuka uses os.environ.get( "OS", "xbox" )

The reason for the "xbox" part is os.environ.get("OS") will fail on xbox, so to you have to add "xbox" as a second parameter so it knows what to return. Otherwise you'll get an exception and your script will fail.
Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
Reply
#5
Thank you all for answering my question about platform detection. It solved the problem in my Navi-X script. I didn't expect it to be that simple.

Rodejo
Reply

Logout Mark Read Team Forum Stats Members Help
Platform/OS detection0