Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python3....
File: platform.py
#! /usr/bin/python3.8
[0] Fix | Delete
[1] Fix | Delete
""" This module tries to retrieve as much platform-identifying data as
[2] Fix | Delete
possible. It makes this information available via function APIs.
[3] Fix | Delete
[4] Fix | Delete
If called from the command line, it prints the platform
[5] Fix | Delete
information concatenated as single string to stdout. The output
[6] Fix | Delete
format is useable as part of a filename.
[7] Fix | Delete
[8] Fix | Delete
"""
[9] Fix | Delete
# This module is maintained by Marc-Andre Lemburg <mal@egenix.com>.
[10] Fix | Delete
# If you find problems, please submit bug reports/patches via the
[11] Fix | Delete
# Python bug tracker (http://bugs.python.org) and assign them to "lemburg".
[12] Fix | Delete
#
[13] Fix | Delete
# Still needed:
[14] Fix | Delete
# * support for MS-DOS (PythonDX ?)
[15] Fix | Delete
# * support for Amiga and other still unsupported platforms running Python
[16] Fix | Delete
# * support for additional Linux distributions
[17] Fix | Delete
#
[18] Fix | Delete
# Many thanks to all those who helped adding platform-specific
[19] Fix | Delete
# checks (in no particular order):
[20] Fix | Delete
#
[21] Fix | Delete
# Charles G Waldman, David Arnold, Gordon McMillan, Ben Darnell,
[22] Fix | Delete
# Jeff Bauer, Cliff Crawford, Ivan Van Laningham, Josef
[23] Fix | Delete
# Betancourt, Randall Hopper, Karl Putland, John Farrell, Greg
[24] Fix | Delete
# Andruk, Just van Rossum, Thomas Heller, Mark R. Levinson, Mark
[25] Fix | Delete
# Hammond, Bill Tutt, Hans Nowak, Uwe Zessin (OpenVMS support),
[26] Fix | Delete
# Colin Kong, Trent Mick, Guido van Rossum, Anthony Baxter, Steve
[27] Fix | Delete
# Dower
[28] Fix | Delete
#
[29] Fix | Delete
# History:
[30] Fix | Delete
#
[31] Fix | Delete
# <see CVS and SVN checkin messages for history>
[32] Fix | Delete
#
[33] Fix | Delete
# 1.0.8 - changed Windows support to read version from kernel32.dll
[34] Fix | Delete
# 1.0.7 - added DEV_NULL
[35] Fix | Delete
# 1.0.6 - added linux_distribution()
[36] Fix | Delete
# 1.0.5 - fixed Java support to allow running the module on Jython
[37] Fix | Delete
# 1.0.4 - added IronPython support
[38] Fix | Delete
# 1.0.3 - added normalization of Windows system name
[39] Fix | Delete
# 1.0.2 - added more Windows support
[40] Fix | Delete
# 1.0.1 - reformatted to make doc.py happy
[41] Fix | Delete
# 1.0.0 - reformatted a bit and checked into Python CVS
[42] Fix | Delete
# 0.8.0 - added sys.version parser and various new access
[43] Fix | Delete
# APIs (python_version(), python_compiler(), etc.)
[44] Fix | Delete
# 0.7.2 - fixed architecture() to use sizeof(pointer) where available
[45] Fix | Delete
# 0.7.1 - added support for Caldera OpenLinux
[46] Fix | Delete
# 0.7.0 - some fixes for WinCE; untabified the source file
[47] Fix | Delete
# 0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and
[48] Fix | Delete
# vms_lib.getsyi() configured
[49] Fix | Delete
# 0.6.1 - added code to prevent 'uname -p' on platforms which are
[50] Fix | Delete
# known not to support it
[51] Fix | Delete
# 0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k;
[52] Fix | Delete
# did some cleanup of the interfaces - some APIs have changed
[53] Fix | Delete
# 0.5.5 - fixed another type in the MacOS code... should have
[54] Fix | Delete
# used more coffee today ;-)
[55] Fix | Delete
# 0.5.4 - fixed a few typos in the MacOS code
[56] Fix | Delete
# 0.5.3 - added experimental MacOS support; added better popen()
[57] Fix | Delete
# workarounds in _syscmd_ver() -- still not 100% elegant
[58] Fix | Delete
# though
[59] Fix | Delete
# 0.5.2 - fixed uname() to return '' instead of 'unknown' in all
[60] Fix | Delete
# return values (the system uname command tends to return
[61] Fix | Delete
# 'unknown' instead of just leaving the field empty)
[62] Fix | Delete
# 0.5.1 - included code for slackware dist; added exception handlers
[63] Fix | Delete
# to cover up situations where platforms don't have os.popen
[64] Fix | Delete
# (e.g. Mac) or fail on socket.gethostname(); fixed libc
[65] Fix | Delete
# detection RE
[66] Fix | Delete
# 0.5.0 - changed the API names referring to system commands to *syscmd*;
[67] Fix | Delete
# added java_ver(); made syscmd_ver() a private
[68] Fix | Delete
# API (was system_ver() in previous versions) -- use uname()
[69] Fix | Delete
# instead; extended the win32_ver() to also return processor
[70] Fix | Delete
# type information
[71] Fix | Delete
# 0.4.0 - added win32_ver() and modified the platform() output for WinXX
[72] Fix | Delete
# 0.3.4 - fixed a bug in _follow_symlinks()
[73] Fix | Delete
# 0.3.3 - fixed popen() and "file" command invocation bugs
[74] Fix | Delete
# 0.3.2 - added architecture() API and support for it in platform()
[75] Fix | Delete
# 0.3.1 - fixed syscmd_ver() RE to support Windows NT
[76] Fix | Delete
# 0.3.0 - added system alias support
[77] Fix | Delete
# 0.2.3 - removed 'wince' again... oh well.
[78] Fix | Delete
# 0.2.2 - added 'wince' to syscmd_ver() supported platforms
[79] Fix | Delete
# 0.2.1 - added cache logic and changed the platform string format
[80] Fix | Delete
# 0.2.0 - changed the API to use functions instead of module globals
[81] Fix | Delete
# since some action take too long to be run on module import
[82] Fix | Delete
# 0.1.0 - first release
[83] Fix | Delete
#
[84] Fix | Delete
# You can always get the latest version of this module at:
[85] Fix | Delete
#
[86] Fix | Delete
# http://www.egenix.com/files/python/platform.py
[87] Fix | Delete
#
[88] Fix | Delete
# If that URL should fail, try contacting the author.
[89] Fix | Delete
[90] Fix | Delete
__copyright__ = """
[91] Fix | Delete
Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
[92] Fix | Delete
Copyright (c) 2000-2010, eGenix.com Software GmbH; mailto:info@egenix.com
[93] Fix | Delete
[94] Fix | Delete
Permission to use, copy, modify, and distribute this software and its
[95] Fix | Delete
documentation for any purpose and without fee or royalty is hereby granted,
[96] Fix | Delete
provided that the above copyright notice appear in all copies and that
[97] Fix | Delete
both that copyright notice and this permission notice appear in
[98] Fix | Delete
supporting documentation or portions thereof, including modifications,
[99] Fix | Delete
that you make.
[100] Fix | Delete
[101] Fix | Delete
EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO
[102] Fix | Delete
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
[103] Fix | Delete
FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
[104] Fix | Delete
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
[105] Fix | Delete
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
[106] Fix | Delete
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
[107] Fix | Delete
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !
[108] Fix | Delete
[109] Fix | Delete
"""
[110] Fix | Delete
[111] Fix | Delete
__version__ = '1.0.8'
[112] Fix | Delete
[113] Fix | Delete
import collections
[114] Fix | Delete
import os
[115] Fix | Delete
import re
[116] Fix | Delete
import sys
[117] Fix | Delete
[118] Fix | Delete
### Globals & Constants
[119] Fix | Delete
[120] Fix | Delete
# Helper for comparing two version number strings.
[121] Fix | Delete
# Based on the description of the PHP's version_compare():
[122] Fix | Delete
# http://php.net/manual/en/function.version-compare.php
[123] Fix | Delete
[124] Fix | Delete
_ver_stages = {
[125] Fix | Delete
# any string not found in this dict, will get 0 assigned
[126] Fix | Delete
'dev': 10,
[127] Fix | Delete
'alpha': 20, 'a': 20,
[128] Fix | Delete
'beta': 30, 'b': 30,
[129] Fix | Delete
'c': 40,
[130] Fix | Delete
'RC': 50, 'rc': 50,
[131] Fix | Delete
# number, will get 100 assigned
[132] Fix | Delete
'pl': 200, 'p': 200,
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
_component_re = re.compile(r'([0-9]+|[._+-])')
[136] Fix | Delete
[137] Fix | Delete
def _comparable_version(version):
[138] Fix | Delete
result = []
[139] Fix | Delete
for v in _component_re.split(version):
[140] Fix | Delete
if v not in '._+-':
[141] Fix | Delete
try:
[142] Fix | Delete
v = int(v, 10)
[143] Fix | Delete
t = 100
[144] Fix | Delete
except ValueError:
[145] Fix | Delete
t = _ver_stages.get(v, 0)
[146] Fix | Delete
result.extend((t, v))
[147] Fix | Delete
return result
[148] Fix | Delete
[149] Fix | Delete
### Platform specific APIs
[150] Fix | Delete
[151] Fix | Delete
_libc_search = re.compile(b'(__libc_init)'
[152] Fix | Delete
b'|'
[153] Fix | Delete
b'(GLIBC_([0-9.]+))'
[154] Fix | Delete
b'|'
[155] Fix | Delete
br'(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)', re.ASCII)
[156] Fix | Delete
[157] Fix | Delete
def libc_ver(executable=None, lib='', version='', chunksize=16384):
[158] Fix | Delete
[159] Fix | Delete
""" Tries to determine the libc version that the file executable
[160] Fix | Delete
(which defaults to the Python interpreter) is linked against.
[161] Fix | Delete
[162] Fix | Delete
Returns a tuple of strings (lib,version) which default to the
[163] Fix | Delete
given parameters in case the lookup fails.
[164] Fix | Delete
[165] Fix | Delete
Note that the function has intimate knowledge of how different
[166] Fix | Delete
libc versions add symbols to the executable and thus is probably
[167] Fix | Delete
only useable for executables compiled using gcc.
[168] Fix | Delete
[169] Fix | Delete
The file is read and scanned in chunks of chunksize bytes.
[170] Fix | Delete
[171] Fix | Delete
"""
[172] Fix | Delete
if executable is None:
[173] Fix | Delete
try:
[174] Fix | Delete
ver = os.confstr('CS_GNU_LIBC_VERSION')
[175] Fix | Delete
# parse 'glibc 2.28' as ('glibc', '2.28')
[176] Fix | Delete
parts = ver.split(maxsplit=1)
[177] Fix | Delete
if len(parts) == 2:
[178] Fix | Delete
return tuple(parts)
[179] Fix | Delete
except (AttributeError, ValueError, OSError):
[180] Fix | Delete
# os.confstr() or CS_GNU_LIBC_VERSION value not available
[181] Fix | Delete
pass
[182] Fix | Delete
[183] Fix | Delete
executable = sys.executable
[184] Fix | Delete
[185] Fix | Delete
V = _comparable_version
[186] Fix | Delete
if hasattr(os.path, 'realpath'):
[187] Fix | Delete
# Python 2.2 introduced os.path.realpath(); it is used
[188] Fix | Delete
# here to work around problems with Cygwin not being
[189] Fix | Delete
# able to open symlinks for reading
[190] Fix | Delete
executable = os.path.realpath(executable)
[191] Fix | Delete
with open(executable, 'rb') as f:
[192] Fix | Delete
binary = f.read(chunksize)
[193] Fix | Delete
pos = 0
[194] Fix | Delete
while pos < len(binary):
[195] Fix | Delete
if b'libc' in binary or b'GLIBC' in binary:
[196] Fix | Delete
m = _libc_search.search(binary, pos)
[197] Fix | Delete
else:
[198] Fix | Delete
m = None
[199] Fix | Delete
if not m or m.end() == len(binary):
[200] Fix | Delete
chunk = f.read(chunksize)
[201] Fix | Delete
if chunk:
[202] Fix | Delete
binary = binary[max(pos, len(binary) - 1000):] + chunk
[203] Fix | Delete
pos = 0
[204] Fix | Delete
continue
[205] Fix | Delete
if not m:
[206] Fix | Delete
break
[207] Fix | Delete
libcinit, glibc, glibcversion, so, threads, soversion = [
[208] Fix | Delete
s.decode('latin1') if s is not None else s
[209] Fix | Delete
for s in m.groups()]
[210] Fix | Delete
if libcinit and not lib:
[211] Fix | Delete
lib = 'libc'
[212] Fix | Delete
elif glibc:
[213] Fix | Delete
if lib != 'glibc':
[214] Fix | Delete
lib = 'glibc'
[215] Fix | Delete
version = glibcversion
[216] Fix | Delete
elif V(glibcversion) > V(version):
[217] Fix | Delete
version = glibcversion
[218] Fix | Delete
elif so:
[219] Fix | Delete
if lib != 'glibc':
[220] Fix | Delete
lib = 'libc'
[221] Fix | Delete
if soversion and (not version or V(soversion) > V(version)):
[222] Fix | Delete
version = soversion
[223] Fix | Delete
if threads and version[-len(threads):] != threads:
[224] Fix | Delete
version = version + threads
[225] Fix | Delete
pos = m.end()
[226] Fix | Delete
return lib, version
[227] Fix | Delete
[228] Fix | Delete
def _norm_version(version, build=''):
[229] Fix | Delete
[230] Fix | Delete
""" Normalize the version and build strings and return a single
[231] Fix | Delete
version string using the format major.minor.build (or patchlevel).
[232] Fix | Delete
"""
[233] Fix | Delete
l = version.split('.')
[234] Fix | Delete
if build:
[235] Fix | Delete
l.append(build)
[236] Fix | Delete
try:
[237] Fix | Delete
strings = list(map(str, map(int, l)))
[238] Fix | Delete
except ValueError:
[239] Fix | Delete
strings = l
[240] Fix | Delete
version = '.'.join(strings[:3])
[241] Fix | Delete
return version
[242] Fix | Delete
[243] Fix | Delete
_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
[244] Fix | Delete
r'.*'
[245] Fix | Delete
r'\[.* ([\d.]+)\])')
[246] Fix | Delete
[247] Fix | Delete
# Examples of VER command output:
[248] Fix | Delete
#
[249] Fix | Delete
# Windows 2000: Microsoft Windows 2000 [Version 5.00.2195]
[250] Fix | Delete
# Windows XP: Microsoft Windows XP [Version 5.1.2600]
[251] Fix | Delete
# Windows Vista: Microsoft Windows [Version 6.0.6002]
[252] Fix | Delete
#
[253] Fix | Delete
# Note that the "Version" string gets localized on different
[254] Fix | Delete
# Windows versions.
[255] Fix | Delete
[256] Fix | Delete
def _syscmd_ver(system='', release='', version='',
[257] Fix | Delete
[258] Fix | Delete
supported_platforms=('win32', 'win16', 'dos')):
[259] Fix | Delete
[260] Fix | Delete
""" Tries to figure out the OS version used and returns
[261] Fix | Delete
a tuple (system, release, version).
[262] Fix | Delete
[263] Fix | Delete
It uses the "ver" shell command for this which is known
[264] Fix | Delete
to exists on Windows, DOS. XXX Others too ?
[265] Fix | Delete
[266] Fix | Delete
In case this fails, the given parameters are used as
[267] Fix | Delete
defaults.
[268] Fix | Delete
[269] Fix | Delete
"""
[270] Fix | Delete
if sys.platform not in supported_platforms:
[271] Fix | Delete
return system, release, version
[272] Fix | Delete
[273] Fix | Delete
# Try some common cmd strings
[274] Fix | Delete
import subprocess
[275] Fix | Delete
for cmd in ('ver', 'command /c ver', 'cmd /c ver'):
[276] Fix | Delete
try:
[277] Fix | Delete
info = subprocess.check_output(cmd,
[278] Fix | Delete
stderr=subprocess.DEVNULL,
[279] Fix | Delete
text=True,
[280] Fix | Delete
shell=True)
[281] Fix | Delete
except (OSError, subprocess.CalledProcessError) as why:
[282] Fix | Delete
#print('Command %s failed: %s' % (cmd, why))
[283] Fix | Delete
continue
[284] Fix | Delete
else:
[285] Fix | Delete
break
[286] Fix | Delete
else:
[287] Fix | Delete
return system, release, version
[288] Fix | Delete
[289] Fix | Delete
# Parse the output
[290] Fix | Delete
info = info.strip()
[291] Fix | Delete
m = _ver_output.match(info)
[292] Fix | Delete
if m is not None:
[293] Fix | Delete
system, release, version = m.groups()
[294] Fix | Delete
# Strip trailing dots from version and release
[295] Fix | Delete
if release[-1] == '.':
[296] Fix | Delete
release = release[:-1]
[297] Fix | Delete
if version[-1] == '.':
[298] Fix | Delete
version = version[:-1]
[299] Fix | Delete
# Normalize the version and build strings (eliminating additional
[300] Fix | Delete
# zeros)
[301] Fix | Delete
version = _norm_version(version)
[302] Fix | Delete
return system, release, version
[303] Fix | Delete
[304] Fix | Delete
_WIN32_CLIENT_RELEASES = {
[305] Fix | Delete
(5, 0): "2000",
[306] Fix | Delete
(5, 1): "XP",
[307] Fix | Delete
# Strictly, 5.2 client is XP 64-bit, but platform.py historically
[308] Fix | Delete
# has always called it 2003 Server
[309] Fix | Delete
(5, 2): "2003Server",
[310] Fix | Delete
(5, None): "post2003",
[311] Fix | Delete
[312] Fix | Delete
(6, 0): "Vista",
[313] Fix | Delete
(6, 1): "7",
[314] Fix | Delete
(6, 2): "8",
[315] Fix | Delete
(6, 3): "8.1",
[316] Fix | Delete
(6, None): "post8.1",
[317] Fix | Delete
[318] Fix | Delete
(10, 0): "10",
[319] Fix | Delete
(10, None): "post10",
[320] Fix | Delete
}
[321] Fix | Delete
[322] Fix | Delete
# Server release name lookup will default to client names if necessary
[323] Fix | Delete
_WIN32_SERVER_RELEASES = {
[324] Fix | Delete
(5, 2): "2003Server",
[325] Fix | Delete
[326] Fix | Delete
(6, 0): "2008Server",
[327] Fix | Delete
(6, 1): "2008ServerR2",
[328] Fix | Delete
(6, 2): "2012Server",
[329] Fix | Delete
(6, 3): "2012ServerR2",
[330] Fix | Delete
(6, None): "post2012ServerR2",
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
def win32_is_iot():
[334] Fix | Delete
return win32_edition() in ('IoTUAP', 'NanoServer', 'WindowsCoreHeadless', 'IoTEdgeOS')
[335] Fix | Delete
[336] Fix | Delete
def win32_edition():
[337] Fix | Delete
try:
[338] Fix | Delete
try:
[339] Fix | Delete
import winreg
[340] Fix | Delete
except ImportError:
[341] Fix | Delete
import _winreg as winreg
[342] Fix | Delete
except ImportError:
[343] Fix | Delete
pass
[344] Fix | Delete
else:
[345] Fix | Delete
try:
[346] Fix | Delete
cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
[347] Fix | Delete
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key:
[348] Fix | Delete
return winreg.QueryValueEx(key, 'EditionId')[0]
[349] Fix | Delete
except OSError:
[350] Fix | Delete
pass
[351] Fix | Delete
[352] Fix | Delete
return None
[353] Fix | Delete
[354] Fix | Delete
def win32_ver(release='', version='', csd='', ptype=''):
[355] Fix | Delete
try:
[356] Fix | Delete
from sys import getwindowsversion
[357] Fix | Delete
except ImportError:
[358] Fix | Delete
return release, version, csd, ptype
[359] Fix | Delete
[360] Fix | Delete
winver = getwindowsversion()
[361] Fix | Delete
try:
[362] Fix | Delete
major, minor, build = map(int, _syscmd_ver()[2].split('.'))
[363] Fix | Delete
except ValueError:
[364] Fix | Delete
major, minor, build = winver.platform_version or winver[:3]
[365] Fix | Delete
version = '{0}.{1}.{2}'.format(major, minor, build)
[366] Fix | Delete
[367] Fix | Delete
release = (_WIN32_CLIENT_RELEASES.get((major, minor)) or
[368] Fix | Delete
_WIN32_CLIENT_RELEASES.get((major, None)) or
[369] Fix | Delete
release)
[370] Fix | Delete
[371] Fix | Delete
# getwindowsversion() reflect the compatibility mode Python is
[372] Fix | Delete
# running under, and so the service pack value is only going to be
[373] Fix | Delete
# valid if the versions match.
[374] Fix | Delete
if winver[:2] == (major, minor):
[375] Fix | Delete
try:
[376] Fix | Delete
csd = 'SP{}'.format(winver.service_pack_major)
[377] Fix | Delete
except AttributeError:
[378] Fix | Delete
if csd[:13] == 'Service Pack ':
[379] Fix | Delete
csd = 'SP' + csd[13:]
[380] Fix | Delete
[381] Fix | Delete
# VER_NT_SERVER = 3
[382] Fix | Delete
if getattr(winver, 'product_type', None) == 3:
[383] Fix | Delete
release = (_WIN32_SERVER_RELEASES.get((major, minor)) or
[384] Fix | Delete
_WIN32_SERVER_RELEASES.get((major, None)) or
[385] Fix | Delete
release)
[386] Fix | Delete
[387] Fix | Delete
try:
[388] Fix | Delete
try:
[389] Fix | Delete
import winreg
[390] Fix | Delete
except ImportError:
[391] Fix | Delete
import _winreg as winreg
[392] Fix | Delete
except ImportError:
[393] Fix | Delete
pass
[394] Fix | Delete
else:
[395] Fix | Delete
try:
[396] Fix | Delete
cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
[397] Fix | Delete
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key:
[398] Fix | Delete
ptype = winreg.QueryValueEx(key, 'CurrentType')[0]
[399] Fix | Delete
except OSError:
[400] Fix | Delete
pass
[401] Fix | Delete
[402] Fix | Delete
return release, version, csd, ptype
[403] Fix | Delete
[404] Fix | Delete
[405] Fix | Delete
def _mac_ver_xml():
[406] Fix | Delete
fn = '/System/Library/CoreServices/SystemVersion.plist'
[407] Fix | Delete
if not os.path.exists(fn):
[408] Fix | Delete
return None
[409] Fix | Delete
[410] Fix | Delete
try:
[411] Fix | Delete
import plistlib
[412] Fix | Delete
except ImportError:
[413] Fix | Delete
return None
[414] Fix | Delete
[415] Fix | Delete
with open(fn, 'rb') as f:
[416] Fix | Delete
pl = plistlib.load(f)
[417] Fix | Delete
release = pl['ProductVersion']
[418] Fix | Delete
versioninfo = ('', '', '')
[419] Fix | Delete
machine = os.uname().machine
[420] Fix | Delete
if machine in ('ppc', 'Power Macintosh'):
[421] Fix | Delete
# Canonical name
[422] Fix | Delete
machine = 'PowerPC'
[423] Fix | Delete
[424] Fix | Delete
return release, versioninfo, machine
[425] Fix | Delete
[426] Fix | Delete
[427] Fix | Delete
def mac_ver(release='', versioninfo=('', '', ''), machine=''):
[428] Fix | Delete
[429] Fix | Delete
""" Get macOS version information and return it as tuple (release,
[430] Fix | Delete
versioninfo, machine) with versioninfo being a tuple (version,
[431] Fix | Delete
dev_stage, non_release_version).
[432] Fix | Delete
[433] Fix | Delete
Entries which cannot be determined are set to the parameter values
[434] Fix | Delete
which default to ''. All tuple entries are strings.
[435] Fix | Delete
"""
[436] Fix | Delete
[437] Fix | Delete
# First try reading the information from an XML file which should
[438] Fix | Delete
# always be present
[439] Fix | Delete
info = _mac_ver_xml()
[440] Fix | Delete
if info is not None:
[441] Fix | Delete
return info
[442] Fix | Delete
[443] Fix | Delete
# If that also doesn't work return the default values
[444] Fix | Delete
return release, versioninfo, machine
[445] Fix | Delete
[446] Fix | Delete
def _java_getprop(name, default):
[447] Fix | Delete
[448] Fix | Delete
from java.lang import System
[449] Fix | Delete
try:
[450] Fix | Delete
value = System.getProperty(name)
[451] Fix | Delete
if value is None:
[452] Fix | Delete
return default
[453] Fix | Delete
return value
[454] Fix | Delete
except AttributeError:
[455] Fix | Delete
return default
[456] Fix | Delete
[457] Fix | Delete
def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):
[458] Fix | Delete
[459] Fix | Delete
""" Version interface for Jython.
[460] Fix | Delete
[461] Fix | Delete
Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being
[462] Fix | Delete
a tuple (vm_name, vm_release, vm_vendor) and osinfo being a
[463] Fix | Delete
tuple (os_name, os_version, os_arch).
[464] Fix | Delete
[465] Fix | Delete
Values which cannot be determined are set to the defaults
[466] Fix | Delete
given as parameters (which all default to '').
[467] Fix | Delete
[468] Fix | Delete
"""
[469] Fix | Delete
# Import the needed APIs
[470] Fix | Delete
try:
[471] Fix | Delete
import java.lang
[472] Fix | Delete
except ImportError:
[473] Fix | Delete
return release, vendor, vminfo, osinfo
[474] Fix | Delete
[475] Fix | Delete
vendor = _java_getprop('java.vendor', vendor)
[476] Fix | Delete
release = _java_getprop('java.version', release)
[477] Fix | Delete
vm_name, vm_release, vm_vendor = vminfo
[478] Fix | Delete
vm_name = _java_getprop('java.vm.name', vm_name)
[479] Fix | Delete
vm_vendor = _java_getprop('java.vm.vendor', vm_vendor)
[480] Fix | Delete
vm_release = _java_getprop('java.vm.version', vm_release)
[481] Fix | Delete
vminfo = vm_name, vm_release, vm_vendor
[482] Fix | Delete
os_name, os_version, os_arch = osinfo
[483] Fix | Delete
os_arch = _java_getprop('java.os.arch', os_arch)
[484] Fix | Delete
os_name = _java_getprop('java.os.name', os_name)
[485] Fix | Delete
os_version = _java_getprop('java.os.version', os_version)
[486] Fix | Delete
osinfo = os_name, os_version, os_arch
[487] Fix | Delete
[488] Fix | Delete
return release, vendor, vminfo, osinfo
[489] Fix | Delete
[490] Fix | Delete
### System name aliasing
[491] Fix | Delete
[492] Fix | Delete
def system_alias(system, release, version):
[493] Fix | Delete
[494] Fix | Delete
""" Returns (system, release, version) aliased to common
[495] Fix | Delete
marketing names used for some systems.
[496] Fix | Delete
[497] Fix | Delete
It also does some reordering of the information in some cases
[498] Fix | Delete
where it would otherwise cause confusion.
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function