Detect current platform?
#1
Quick question... is there a way for an addon to find out which platform it's running on?

Basically I want to know if the addon is running on Android as in that case I need to handle settings differently so would be useful if it was possible.

Thanks in advance!
Reply
#2
I use xbmc.getCondVisibility(), though android is detected as linux too. Im far from a python wiz, so there are probably better ways of getting the current platform, but here is how I do it

https://github.com/teeedubb/teeedubb-xbm...default.py
Reply
#3
That's great, thanks! Smile

(2015-02-27, 12:38)teeedubb Wrote: though android is detected as linux too.

Does that mean on an Android device you get a True for both of these then?
Code:
osLinux = xbmc.getCondVisibility('system.platform.linux')
osAndroid = xbmc.getCondVisibility('system.platform.android')

If so I guess if I first check for Android that should cover it, as a Linux PC shouldn't be detected as Android, right?
Reply
#4
From memory xbmc.getCondVisibility('system.platform.android') returns true for linux and android (though I last tested on gotham), which is why I use

if osAndroid:
osLinux = 0
Reply
#5
Perfect! Thank you Smile
Reply
#6
(2015-02-27, 12:50)teeedubb Wrote: From memory xbmc.getCondVisibility('system.platform.android') returns true for linux and android (though I last tested on gotham), which is why I use

if osAndroid:
osLinux = 0

if that's so i would see that as a flaw.

@mkortstiege?
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#7
(2015-02-27, 12:38)teeedubb Wrote: I use xbmc.getCondVisibility(), though android is detected as linux too. Im far from a python wiz, so there are probably better ways of getting the current platform, but here is how I do it

https://github.com/teeedubb/teeedubb-xbm...default.py

Thanks for the info Smile
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#8
According to: http://forum.kodi.tv/showthread.php?tid=125005 : sys.platform should also work. It should return the platform for the Kodi install ie 'win32' even on a Win64 OS.

Edit: on an android arm I got 'linux3' so this may not help a lot of folks.

Did some more digging:

Code:
from platform import system, architecture, machine, release, version

OS_SYSTEM = system()
OS_ARCH_BIT = architecture()[0]
OS_ARCH_LINK = architecture()[1]
OS_MACHINE = machine()
OS_RELEASE = release()
OS_VERSION = version()
OS_DETECT = OS_SYSTEM + '-' + OS_ARCH_BIT + '-' + OS_ARCH_LINK
OS_DETECT += ' | host: [%s][%s][%s]' %(OS_MACHINE, OS_RELEASE, OS_VERSION)

Code:
output on windows: OS_DETECT: Windows-32bit-WindowsPE | host: [AMD64][post2012Server][6.3.9600]
output on android: OS_DETECT: Linux-32bit- | host: [armv7l][3.4.105-gda54a646][#2 SMP PREEMPT Tue Feb 17 17:27:03 CST 2015]

Granted, some information isn't too useful.

Sadly I know it can be as good as "Platform: Windows NT x86 32-bit" or "Platform: Android ARM 32-bit" (Kodi spits this out at the top of the log) yet I can't find where/how it's getting that info. As far as I can tell, it comes from get_platform() in sysconfig.py but even importing that function doesn't provide the same output as in the log. I instead get the same thing as pulling sys.platform.
Reply
#9
What is the status of pull request 5837?

https://github.com/xbmc/xbmc/pull/5837
Reply
#10
I also use the boolean conditions for this and also came across this "problem" between android and linux. Android is detected as both linux and android but linux never reported as android so, it's quite easy to overcome.

if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.android') --> Linux
if xbmc.getCondVisibility('system.platform.linux') and xbmc.getCondVisibility('system.platform.android') --> Android


Always thought it worked this way on purpose due to the linux kernel in android.
Reply

Logout Mark Read Team Forum Stats Members Help
Detect current platform?0