Lines Matching +full:os +full:- +full:release
3 """ This module tries to retrieve as much platform-identifying data as
11 # This module is maintained by Marc-Andre Lemburg <mal@egenix.com>.
19 # * support for MS-DOS (PythonDX ?)
23 # Many thanks to all those who helped adding platform-specific
38 # 1.0.8 - changed Windows support to read version from kernel32.dll
39 # 1.0.7 - added DEV_NULL
40 # 1.0.6 - added linux_distribution()
41 # 1.0.5 - fixed Java support to allow running the module on Jython
42 # 1.0.4 - added IronPython support
43 # 1.0.3 - added normalization of Windows system name
44 # 1.0.2 - added more Windows support
45 # 1.0.1 - reformatted to make doc.py happy
46 # 1.0.0 - reformatted a bit and checked into Python CVS
47 # 0.8.0 - added sys.version parser and various new access
49 # 0.7.2 - fixed architecture() to use sizeof(pointer) where available
50 # 0.7.1 - added support for Caldera OpenLinux
51 # 0.7.0 - some fixes for WinCE; untabified the source file
52 # 0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and
54 # 0.6.1 - added code to prevent 'uname -p' on platforms which are
56 # 0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k;
57 # did some cleanup of the interfaces - some APIs have changed
58 # 0.5.5 - fixed another type in the MacOS code... should have
59 # used more coffee today ;-)
60 # 0.5.4 - fixed a few typos in the MacOS code
61 # 0.5.3 - added experimental MacOS support; added better popen()
62 # workarounds in _syscmd_ver() -- still not 100% elegant
64 # 0.5.2 - fixed uname() to return '' instead of 'unknown' in all
67 # 0.5.1 - included code for slackware dist; added exception handlers
68 # to cover up situations where platforms don't have os.popen
71 # 0.5.0 - changed the API names referring to system commands to *syscmd*;
73 # API (was system_ver() in previous versions) -- use uname()
76 # 0.4.0 - added win32_ver() and modified the platform() output for WinXX
77 # 0.3.4 - fixed a bug in _follow_symlinks()
78 # 0.3.3 - fixed popen() and "file" command invokation bugs
79 # 0.3.2 - added architecture() API and support for it in platform()
80 # 0.3.1 - fixed syscmd_ver() RE to support Windows NT
81 # 0.3.0 - added system alias support
82 # 0.2.3 - removed 'wince' again... oh well.
83 # 0.2.2 - added 'wince' to syscmd_ver() supported platforms
84 # 0.2.1 - added cache logic and changed the platform string format
85 # 0.2.0 - changed the API to use functions instead of module globals
87 # 0.1.0 - first release
96 Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
97 Copyright (c) 2000-2010, eGenix.com Software GmbH; mailto:info@egenix.com
118 import sys,string,os,re
124 DEV_NULL = os.devnull
126 # os.devnull was added in Python 2.4, so emulate it for earlier
137 # http://php.net/manual/en/function.version-compare.php
150 _component_re = re.compile(r'([0-9]+|[._+-])')
155 if v not in '._+-':
168 '(GLIBC_([0-9.]+))'
170 '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)')
188 if hasattr(os.path, 'realpath'):
189 # Python 2.2 introduced os.path.realpath(); it is used
192 executable = os.path.realpath(executable)
201 binary = binary[max(pos, len(binary) - 1000):] + chunk
220 if threads and version[-len(threads):] != threads:
234 if os.path.exists('/var/adm/inst-log/info'):
236 info = open('/var/adm/inst-log/info').readlines()
247 values = string.split(value,'-')
251 if os.path.exists('/etc/.installed'):
255 pkg = string.split(line,'-')
261 if os.path.isdir('/usr/lib/setup'):
263 verfiles = os.listdir('/usr/lib/setup')
264 for n in range(len(verfiles)-1, -1, -1):
265 if verfiles[n][:14] != 'slack-version-':
270 version = verfiles[-1][14:]
275 _release_filename = re.compile(r'(\w+)[-_](release|version)')
277 ' release '
280 _release_version = re.compile(r'([^0-9]+)'
281 '(?: release )?'
286 # and http://linuxmafia.com/faq/Admin/release-files.html
287 # and http://data.linux-ntfs.org/rpm/whichrpm
306 # LSB format: "distro release x.x (codename)"
309 # Pre-LSB format: "distro x.x (codename)"
327 """ Tries to determine the name of the Linux OS distribution name.
329 The function first looks for a distribution release file in
335 supported Linux distributions identified by their release file
339 distribution read from the OS is returned. Otherwise the short
347 etc = os.listdir('/etc')
348 except os.error:
382 """ Tries to determine the name of the Linux OS distribution name.
384 The function first looks for a distribution release file in
400 This is mostly needed in case os.popen() is not available, or
415 raise ValueError,'popen()-emulation only supports read mode'
418 os.system(cmd + ' > %s' % tmpfile)
434 remove=os.unlink,error=os.error):
455 # over os.popen over _popen
457 if os.environ.get('OS','') == 'Windows_NT':
467 if hasattr(os,'popen'):
468 popen = os.popen
474 except os.error:
514 def _syscmd_ver(system='', release='', version='', argument
518 """ Tries to figure out the OS version used and returns
519 a tuple (system,release,version).
522 to exists on Windows, DOS and OS/2. XXX Others too ?
529 return system,release,version
537 raise os.error,'command failed'
540 except os.error,why:
549 return system,release,version
555 system,release,version = m.groups()
556 # Strip trailing dots from version and release
557 if release[-1] == '.':
558 release = release[:-1]
559 if version[-1] == '.':
560 version = version[:-1]
564 return system,release,version
569 # Strictly, 5.2 client is XP 64-bit, but platform.py historically
584 # Server release name lookup will default to client names if necessary
656 def win32_ver(release='', version='', csd='', ptype=''): argument
660 return release, version, csd, ptype
670 release = (_WIN32_CLIENT_RELEASES.get((maj, min)) or
672 release)
686 release = (_WIN32_SERVER_RELEASES.get((maj, min)) or
688 release)
701 return release, version, csd, ptype
749 release = '%i.%i.%i' %(major, minor, patch)
751 release = '%s.%i.%i' % (_bcd2str(major),minor,patch)
759 return release,versioninfo,machine
763 if not os.path.exists(fn):
772 release = pl['ProductVersion']
774 machine = os.uname()[4]
779 return release,versioninfo,machine
782 def mac_ver(release='',versioninfo=('','',''),machine=''): argument
784 """ Get MacOS version information and return it as tuple (release,
805 return release,versioninfo,machine
818 def java_ver(release='',vendor='',vminfo=('','',''),osinfo=('','','')): argument
822 Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being
834 return release,vendor,vminfo,osinfo
837 release = _java_getprop('java.version', release)
844 os_arch = _java_getprop('java.os.arch', os_arch)
845 os_name = _java_getprop('java.os.name', os_name)
846 os_version = _java_getprop('java.os.version', os_version)
849 return release, vendor, vminfo, osinfo
853 def system_alias(system,release,version): argument
855 """ Returns (system,release,version) aliased to common
864 # XXX How can we determine the marketing release number ?
865 return 'MacOS X Server',system+release,version
868 # Sun's OS
869 if release < '5':
871 return system,release,version
872 # Modify release (marketing release = SunOS release - 3)
873 l = string.split(release,'.')
880 major = major - 3
882 release = string.join(l,'.')
883 if release < '6':
890 # IRIX reports IRIX64 on platforms with 64-bit support; yet it
891 # is really a version and not a different platform, since 32-bit
903 return system,release,version
910 compatible format e.g. "system-version-machine".
916 '-')
921 platform = replace(platform,'/','-')
922 platform = replace(platform,'\\','-')
923 platform = replace(platform,':','-')
924 platform = replace(platform,';','-')
925 platform = replace(platform,'"','-')
926 platform = replace(platform,'(','-')
927 platform = replace(platform,')','-')
932 # Fold '--'s and remove trailing '-'
934 cleaned = replace(platform,'--','-')
938 while platform[-1] == '-':
939 platform = platform[:-1]
958 # os.path.abspath is new in Python 1.5.2:
959 if not hasattr(os.path,'abspath'):
963 isabs=os.path.isabs,join=os.path.join,getcwd=os.getcwd,
964 normpath=os.path.normpath):
972 _abspath = os.path.abspath
980 while os.path.islink(filepath):
981 filepath = os.path.normpath(
982 os.path.join(os.path.dirname(filepath),os.readlink(filepath)))
993 f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
994 except (AttributeError,os.error):
1007 The function uses the -b option of the file command to have it
1008 ommit the filename in its output and if possible the -L option
1019 # gcc -o python \
1021 # libpython2.7.a -lsocket -lnsl -ldl -lm
1026 # import sys,string,os,re,subprocess
1041 except (AttributeError,os.error):
1052 # Default values for architecture; non-empty strings override the
1078 platforms. On some non-Unix platforms where the "file" command
1120 if '32-bit' in fileout:
1125 elif '64-bit' in fileout:
1139 elif 'MS-DOS' in fileout:
1154 of strings (system,node,release,version,machine,processor)
1157 Note that unlike the os.uname function this also returns
1171 # Get some infos from the builtin os.uname API...
1173 system,node,release,version,machine = os.uname()
1177 if no_os_uname or not filter(None, (system, node, release, version, machine)):
1182 release = ''
1191 release,version,csd,ptype = win32_ver()
1192 if release and version:
1200 if "PROCESSOR_ARCHITEW6432" in os.environ:
1201 machine = os.environ.get("PROCESSOR_ARCHITEW6432", '')
1203 machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
1205 processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
1210 system,release,version = _syscmd_ver(system)
1215 elif system == 'Microsoft' and release == 'Windows':
1218 # release is no longer printed. This causes the
1219 # system and release to be misidentified.
1222 release = 'Vista'
1224 release = ''
1237 release,vendor,vminfo,osinfo = java_ver()
1245 # OpenVMS seems to have release and version mixed up
1246 if not release or release == '0':
1247 release = version
1262 processor = _syscmd_uname('-p','')
1269 if release == 'unknown':
1270 release = ''
1279 if system == 'Microsoft' and release == 'Windows':
1281 release = 'Vista'
1283 _uname_cache = system,node,release,version,machine,processor
1290 """ Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'.
1307 def release(): function
1309 """ Returns the system's release, e.g. '2.2.0' or 'NT'
1318 """ Returns the system's release version, e.g. '#3 on degas'
1366 '\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)'
1556 ### The Opus Magnum of platform strings :-)
1585 system,node,release,version,machine,processor = uname()
1589 system,release,version = system_alias(system,release,version)
1595 platform = _platform(system,release)
1597 platform = _platform(system,release,version,csd)
1603 platform = _platform(system,release,machine,processor,
1609 platform = _platform(system,release,machine,processor,
1616 platform = _platform(system,release,version)
1618 platform = _platform(system,release,version,
1625 platform = _platform(system,release)
1627 platform = _platform(system,release,machine)
1632 platform = _platform(system,release)
1635 platform = _platform(system,release,machine,processor,bits,linkage)
1644 terse = ('terse' in sys.argv or '--terse' in sys.argv)
1645 aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv)