Module platform

This module tries to retrieve as much platform-identifying data as
possible. It makes this information available via function APIs.

If called from the command line, it prints the platform information
concatenated as single string to stdout. The output format is useable as
part of a filename.

Version:
1.0.4

Copyright:
Copyright (c) 1999-2000, Marc-Andre Lemburg;
mailto:mal@lemburg.com
Copyright (c) 2000-2003, eGenix.com Software GmbH;
mailto:info@egenix.com
Permission to use, copy, modify, and distribute this software
and its
documentation for any purpose and without fee or royalty is
hereby granted,
provided that the above copyright notice appear in all copies
and that
both that copyright notice and this permission notice appear in
supporting documentation or portions thereof, including
modifications,
that you make.
EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD
TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
SPECIAL,
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !

_norm_version(version,
build='')
Normalize the version and build strings and return a single version
string using the format major.minor.build (or patchlevel).

_syscmd_ver(system='',
release='',
version='',
supported_platforms=('win32', 'win16', 'dos', 'os2'))
Tries to figure out the OS version used and returns a tuple
(system,release,version).

_win32_getvalue(key,
name,
default='')
Read a value for name from the registry key.

win32_ver(release='',
version='',
csd='',
ptype='')
Get additional version information from the Windows Registry and
return a tuple (version,csd,ptype) referring to version number, CSD
level and OS type (multi/single processor).

_mac_ver_lookup(selectors,
default=None)

_bcd2str(bcd)

mac_ver(release='',
versioninfo=('', '', ''),
machine='')
Get MacOS version information and return it as tuple (release,
versioninfo, machine) with versioninfo being a tuple (version,
dev_stage, non_release_version).

Tries to figure out the OS version used and returns a tuple
(system,release,version).

It uses the "ver" shell command for this which is known to
exists on Windows, DOS and OS/2. XXX Others too ?

In case this fails, the given parameters are used as defaults.

_win32_getvalue(key,
name,
default='')

Read a value for name from the registry key.

In case this fails, default is returned.

win32_ver(release='',
version='',
csd='',
ptype='')

Get additional version information from the Windows Registry and
return a tuple (version,csd,ptype) referring to version number, CSD level
and OS type (multi/single processor).

As a hint: ptype returns 'Uniprocessor Free' on single processor NT
machines and 'Multiprocessor Free' on multi processor machines. The
'Free' refers to the OS version being free of debugging code. It could
also state 'Checked' which means the OS version uses debugging code, i.e.
code that checks arguments, ranges, etc. (Thomas Heller).

Note: this function only works if Mark Hammond's win32 package is
installed and obviously only runs on Win32 compatible platforms.

mac_ver(release='',
versioninfo=('', '', ''),
machine='')

Get MacOS version information and return it as tuple (release,
versioninfo, machine) with versioninfo being a tuple (version,
dev_stage, non_release_version).
Entries which cannot be determined are set to the paramter values
which default to ''. All tuple entries are strings.
Thanks to Mark R. Levinson for mailing documentation links and
code examples for this function. Documentation for the
gestalt() API is available online at:
http://www.rgaros.nl/gestalt/

Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being a
tuple (vm_name,vm_release,vm_vendor) and osinfo being a tuple
(os_name,os_version,os_arch).

Values which cannot be determined are set to the defaults given as
parameters (which all default to '').

system_alias(system,
release,
version)

Returns (system,release,version) aliased to common marketing names
used for some systems.

It also does some reordering of the information in some cases where it
would otherwise cause confusion.

_platform(*args)

Helper to format the platform string in a filename compatible format
e.g. "system-version-machine".

_syscmd_file(target,
default='')

Interface to the system's file command.

The function uses the -b option of the file command to have it ommit
the filename in its output and if possible the -L option to have the
command follow symlinks. It returns default in case the command should
fail.

_architecture_split(...)

architecture(executable='/usr/bin/python2.5',
bits='',
linkage='')

Queries the given executable (defaults to the Python interpreter
binary) for various architecture information.

Returns a tuple (bits,linkage) which contains information about the
bit architecture and the linkage format used for the executable. Both
values are returned as strings.

Values that cannot be determined are returned as given by the
parameter presets. If bits is given as '', the sizeof(pointer) (or
sizeof(long) on Python version < 1.5.2) is used as indicator for the
supported pointer size.

The function relies on the system's "file" command to do the
actual work. This is available on most if not all Unix platforms. On some
non-Unix platforms where the "file" command does not exist and
the executable is set to the Python interpreter binary defaults from
_default_architecture are used.

uname()

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

Entries which cannot be determined are set to ''.

system()

Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'.

An empty string is returned if the value cannot be determined.

node()

Returns the computer's network name (which may not be fully
qualified)

An empty string is returned if the value cannot be determined.

release()

Returns the system's release, e.g. '2.2.0' or 'NT'

An empty string is returned if the value cannot be determined.

version()

Returns the system's release version, e.g. '#3 on degas'

An empty string is returned if the value cannot be determined.

machine()

Returns the machine type, e.g. 'i386'

An empty string is returned if the value cannot be determined.

processor()

Returns the (true) processor name, e.g. 'amdk6'

An empty string is returned if the value cannot be determined. Note
that many platforms do not provide this information or simply return the
same value as for machine(), e.g. NetBSD does this.

_sys_version()

Returns a parsed version of Python's sys.version as tuple (version,
buildno, builddate, compiler) referring to the Python version, build
number, build date/time as string and the compiler identification
string.

Note that unlike the Python sys.version, the returned value for the
Python version will always include the patchlevel (it defaults to
'.0').

python_version()

Returns the Python version as string 'major.minor.patchlevel'

Note that unlike the Python sys.version, the returned value will
always include the patchlevel (it defaults to 0).

python_version_tuple()

Returns the Python version as tuple (major, minor, patchlevel) of
strings.

Note that unlike the Python sys.version, the returned value will
always include the patchlevel (it defaults to 0).

platform(aliased=0,
terse=0)

Returns a single string identifying the underlying platform with as
much useful information as possible (but no more :).

The output is intended to be human readable rather than machine
parseable. It may look different on different platforms and this is
intended.

If "aliased" is true, the function will use aliases for
various platforms that report system names which differ from their common
names, e.g. SunOS will be reported as Solaris. The system_alias()
function is used to implement this.

Setting terse to true causes the function to return only the absolute
minimum information needed to identify the platform.