• Home
  • Raw
  • Download

Lines Matching +full:default +full:- +full:build +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>.
16 # * support for MS-DOS (PythonDX ?)
20 # Many thanks to all those who helped adding platform-specific
35 # 1.0.8 - changed Windows support to read version from kernel32.dll
36 # 1.0.7 - added DEV_NULL
37 # 1.0.6 - added linux_distribution()
38 # 1.0.5 - fixed Java support to allow running the module on Jython
39 # 1.0.4 - added IronPython support
40 # 1.0.3 - added normalization of Windows system name
41 # 1.0.2 - added more Windows support
42 # 1.0.1 - reformatted to make doc.py happy
43 # 1.0.0 - reformatted a bit and checked into Python CVS
44 # 0.8.0 - added sys.version parser and various new access
46 # 0.7.2 - fixed architecture() to use sizeof(pointer) where available
47 # 0.7.1 - added support for Caldera OpenLinux
48 # 0.7.0 - some fixes for WinCE; untabified the source file
49 # 0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and
51 # 0.6.1 - added code to prevent 'uname -p' on platforms which are
53 # 0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k;
54 # did some cleanup of the interfaces - some APIs have changed
55 # 0.5.5 - fixed another type in the MacOS code... should have
56 # used more coffee today ;-)
57 # 0.5.4 - fixed a few typos in the MacOS code
58 # 0.5.3 - added experimental MacOS support; added better popen()
59 # workarounds in _syscmd_ver() -- still not 100% elegant
61 # 0.5.2 - fixed uname() to return '' instead of 'unknown' in all
64 # 0.5.1 - included code for slackware dist; added exception handlers
68 # 0.5.0 - changed the API names referring to system commands to *syscmd*;
70 # API (was system_ver() in previous versions) -- use uname()
73 # 0.4.0 - added win32_ver() and modified the platform() output for WinXX
74 # 0.3.4 - fixed a bug in _follow_symlinks()
75 # 0.3.3 - fixed popen() and "file" command invocation bugs
76 # 0.3.2 - added architecture() API and support for it in platform()
77 # 0.3.1 - fixed syscmd_ver() RE to support Windows NT
78 # 0.3.0 - added system alias support
79 # 0.2.3 - removed 'wince' again... oh well.
80 # 0.2.2 - added 'wince' to syscmd_ver() supported platforms
81 # 0.2.1 - added cache logic and changed the platform string format
82 # 0.2.0 - changed the API to use functions instead of module globals
84 # 0.1.0 - first release
93 Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
94 Copyright (c) 2000-2010, eGenix.com Software GmbH; mailto:info@egenix.com
126 # http://php.net/manual/en/function.version-compare.php
139 _component_re = re.compile(r'([0-9]+|[._+-])')
144 if v not in '._+-':
157 b'(GLIBC_([0-9.]+))'
159 br'(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)', re.ASCII)
166 Returns a tuple of strings (lib,version) which default to the
209 binary = binary[max(pos, len(binary) - 1000):] + chunk
230 if threads and version[-len(threads):] != threads:
235 def _norm_version(version, build=''): argument
237 """ Normalize the version and build strings and return a single
238 version string using the format major.minor.build (or patchlevel).
241 if build:
242 l.append(build)
263 def _syscmd_ver(system='', release='', version='', argument
268 a tuple (system, release, version).
278 return system, release, version
296 return system, release, version
302 system, release, version = m.groups()
303 # Strip trailing dots from version and release
304 if release[-1] == '.':
305 release = release[:-1]
306 if version[-1] == '.':
307 version = version[:-1]
308 # Normalize the version and build strings (eliminating additional
311 return system, release, version
316 # Strictly, 5.2 client is XP 64-bit, but platform.py historically
331 # Server release name lookup will default to client names if necessary
363 def win32_ver(release='', version='', csd='', ptype=''): argument
367 return release, version, csd, ptype
371 major, minor, build = map(int, _syscmd_ver()[2].split('.'))
373 major, minor, build = winver.platform_version or winver[:3]
374 version = '{0}.{1}.{2}'.format(major, minor, build)
376 release = (_WIN32_CLIENT_RELEASES.get((major, minor)) or
378 release)
392 release = (_WIN32_SERVER_RELEASES.get((major, minor)) or
394 release)
411 return release, version, csd, ptype
426 release = pl['ProductVersion']
433 return release, versioninfo, machine
436 def mac_ver(release='', versioninfo=('', '', ''), machine=''): argument
438 """ Get macOS version information and return it as tuple (release,
443 which default to ''. All tuple entries are strings.
452 # If that also doesn't work return the default values
453 return release, versioninfo, machine
455 def _java_getprop(name, default): argument
461 return default
464 return default
466 def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')): argument
470 Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being
475 given as parameters (which all default to '').
482 return release, vendor, vminfo, osinfo
485 release = _java_getprop('java.version', release)
497 return release, vendor, vminfo, osinfo
501 def system_alias(system, release, version): argument
503 """ Returns (system, release, version) aliased to common
512 if release < '5':
514 return system, release, version
515 # Modify release (marketing release = SunOS release - 3)
516 l = release.split('.')
523 major = major - 3
525 release = '.'.join(l)
526 if release < '6':
536 # bpo-35516: Don't replace Darwin with macOS since input release and
539 return system, release, version
546 compatible format e.g. "system-version-machine".
549 platform = '-'.join(x.strip() for x in filter(len, args))
553 platform = platform.replace('/', '-')
554 platform = platform.replace('\\', '-')
555 platform = platform.replace(':', '-')
556 platform = platform.replace(';', '-')
557 platform = platform.replace('"', '-')
558 platform = platform.replace('(', '-')
559 platform = platform.replace(')', '-')
564 # Fold '--'s and remove trailing '-'
566 cleaned = platform.replace('--', '-')
570 while platform[-1] == '-':
571 platform = platform[:-1]
575 def _node(default=''): argument
583 return default
588 return default
602 def _syscmd_file(target, default=''): argument
606 The function uses the -b option of the file command to have it
608 default in case the command should fail.
613 return default
618 return default
624 # -b: do not prepend filenames to output lines (brief mode)
625 output = subprocess.check_output(['file', '-b', target],
629 return default
631 return default
632 # With the C locale, the output should be mostly ASCII-compatible.
633 # Decode from Latin-1 to prevent Unicode decode error.
634 return output.decode('latin-1')
638 # Default values for architecture; non-empty strings override the
662 platforms. On some non-Unix platforms where the "file" command
667 # Use the sizeof(pointer) as default number of bits if nothing
668 # else is given as default.
697 if '32-bit' in fileout:
699 elif '64-bit' in fileout:
713 elif 'MS-DOS' in fileout:
755 Fall back to `uname -p`
763 ['uname', '-p'],
781 "system node release version machine")
790 _fields = ('system', 'node', 'release', 'version', 'machine', 'processor')
805 num_fields = len(cls._fields) - 1
819 return uname_result, tuple(self)[:len(self._fields) - 1]
828 of strings (system, node, release, version, machine, processor)
844 system, node, release, version, machine = infos = os.uname()
848 release = version = machine = ''
856 release, version, csd, ptype = win32_ver()
861 if not (release and version):
862 system, release, version = _syscmd_ver(system)
867 elif system == 'Microsoft' and release == 'Windows':
870 # release is no longer printed. This causes the
871 # system and release to be misidentified.
874 release = 'Vista'
876 release = ''
889 release, vendor, vminfo, osinfo = java_ver()
897 # OpenVMS seems to have release and version mixed up
898 if not release or release == '0':
899 release = version
903 if system == 'Microsoft' and release == 'Windows':
905 release = 'Vista'
907 vals = system, node, release, version, machine
933 def release(): function
935 """ Returns the system's release, e.g. '2.2.0' or 'NT'
940 return uname().release
944 """ Returns the system's release version, e.g. '#3 on degas'
992 r'\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)'
1007 revision, build number, build date/time as string and the compiler
1101 # Build and cache the result
1170 build number and date as strings.
1183 ### The Opus Magnum of platform strings :-)
1212 system, node, release, version, machine, processor = uname()
1216 system, release, version = system_alias(system, release, version)
1223 release = macos_release
1229 platform = _platform(system, release)
1231 platform = _platform(system, release, version, csd)
1236 platform = _platform(system, release, machine, processor,
1243 platform = _platform(system, release, version)
1245 platform = _platform(system, release, version,
1252 platform = _platform(system, release)
1255 platform = _platform(system, release, machine,
1261 ### freedesktop.org os-release standard
1262 # https://www.freedesktop.org/software/systemd/man/os-release.html
1267 "^(?P<name>[a-zA-Z0-9_]+)=(?P<quote>[\"\']?)(?P<value>.*)(?P=quote)$"
1272 _os_release_candidates = ("/etc/os-release", "/usr/lib/os-release")
1277 # These fields are mandatory fields with well-known defaults
1296 """Return operation system identification from freedesktop.org os-release
1304 with open(candidate, encoding="utf-8") as f:
1321 # Default is to print the aliased verbose platform string
1322 terse = ('terse' in sys.argv or '--terse' in sys.argv)
1323 aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv)