I'll give you an example. I've received some bug reports about AndroidViewClient not being able to find adb. AndroidViewClient tries to be clever and not to invoke adb if it's going to fail because it's not found or it's not executable. To determine this, it is using:
if not os.access(adb, os.X_OK):
raise Exception('adb="%s" is not executable' % adb)
the trick here is that for Windows platforms adb should include the trailing .exe.
Then the problem is to determine the OS the script is running on.
There are several ways of determining the OS in python and jython. Let's see what are the results using monkeyrunner
|Command||Linux||Mac OS X||Windows|
|java.lang.System.getProperty('os.name')||Linux||Mac OS X||Windows XP|
From the previous table we can determine that the best way of obtaining the OS from a monkeyrunner script is
I hope this helps you