Is there a reliable way to determine system architecture using python?

Possible duplicate:
How to return system information in Python?

For example, to see if Solaris is Solaris X86 or Solaris SPARC?

Googled, but did not find anything suitable ...

+4
source share
2 answers

I used the following:

>>> import platform >>> platform.uname() ('Darwin', 'Matthew-Rankins-MacBook-Pro.local', '10.8.0', 'Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64', 'x86_64', 'i386') >>> 

From the Python platform documentation :

platform.uname()

Pretty portable uname interface. Returns a tuple of strings (system, node, release, version, machine, processor) that identifies the underlying platform.

Note that unlike the os.uname() function, this also returns possible processor information as an additional entry in the tuple.

Records that cannot be determined are set to '..

+4
source
 >>> import platform >>> platform.system() 'Darwin' >>> platform.processor() 'i386' >>> platform.platform() 'Darwin-10.8.0-i386-64bit' >>> platform.machine() 'i386' >>> platform.version() 'Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386' >>> platform.uname() ('Darwin', 'Hostname.local', '10.8.0', 'Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386', 'i386', 'i386') 
+3
source

All Articles