What do I need to look at to see if I'm on Windows, Unix, etc?
>>> import os
>>> print os.name
posix
>>> import platform
>>> platform.system()
'Linux'
>>> platform.release()
'2.6.22-15-generic'
Dang -- lbrandy beat me to the punch, but that doesn't mean I can't provide you with the system results for Vista!
>>> import os
>>> print os.name
nt
>>> import platform
>>> platform.system()
'Windows'
>>> platform.release()
'Vista'
Thanks all, for the record here's the results on Mac:
>>> import os >>> os.name 'posix' >>> import platform >>> platform.system() 'Darwin' >>> platform.release() '8.11.1'
You can also use sys.platform if you already have imported sys and you don't want to import another module
>>> import sys
>>> sys.platform
'linux2'
I do this
import sys
print sys.platform
Docs here : http://docs.python.org/library/sys.html#sys.platform. Everything you need is probably in the sys module.
This question has already been answered before: http://stackoverflow.com/questions/1854/python-how-do-i-tell-what-os-im-running-on
I am using the WLST tool that comes with weblogic, and it doesn't implement the platform package.
Apart from patching the system javaos.py (http://osdir.com/ml/lang.jython.devel/2006-08/msg00035.html) (which I can't do, I have to use weblogic out of the box), this is what I use:
def iswindows():
os = java.lang.System.getProperty( "os.name" )
return os.lower().find("win") > -1