Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/imh-pyth.../lib/python3....
File: platform.py
#! /usr/libexec/platform-python -s
[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
import subprocess
[118] Fix | Delete
import functools
[119] Fix | Delete
import itertools
[120] Fix | Delete
[121] Fix | Delete
### Globals & Constants
[122] Fix | Delete
[123] Fix | Delete
# Helper for comparing two version number strings.
[124] Fix | Delete
# Based on the description of the PHP's version_compare():
[125] Fix | Delete
# http://php.net/manual/en/function.version-compare.php
[126] Fix | Delete
[127] Fix | Delete
_ver_stages = {
[128] Fix | Delete
# any string not found in this dict, will get 0 assigned
[129] Fix | Delete
'dev': 10,
[130] Fix | Delete
'alpha': 20, 'a': 20,
[131] Fix | Delete
'beta': 30, 'b': 30,
[132] Fix | Delete
'c': 40,
[133] Fix | Delete
'RC': 50, 'rc': 50,
[134] Fix | Delete
# number, will get 100 assigned
[135] Fix | Delete
'pl': 200, 'p': 200,
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
_component_re = re.compile(r'([0-9]+|[._+-])')
[139] Fix | Delete
[140] Fix | Delete
def _comparable_version(version):
[141] Fix | Delete
result = []
[142] Fix | Delete
for v in _component_re.split(version):
[143] Fix | Delete
if v not in '._+-':
[144] Fix | Delete
try:
[145] Fix | Delete
v = int(v, 10)
[146] Fix | Delete
t = 100
[147] Fix | Delete
except ValueError:
[148] Fix | Delete
t = _ver_stages.get(v, 0)
[149] Fix | Delete
result.extend((t, v))
[150] Fix | Delete
return result
[151] Fix | Delete
[152] Fix | Delete
### Platform specific APIs
[153] Fix | Delete
[154] Fix | Delete
_libc_search = re.compile(b'(__libc_init)'
[155] Fix | Delete
b'|'
[156] Fix | Delete
b'(GLIBC_([0-9.]+))'
[157] Fix | Delete
b'|'
[158] Fix | Delete
br'(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)', re.ASCII)
[159] Fix | Delete
[160] Fix | Delete
def libc_ver(executable=None, lib='', version='', chunksize=16384):
[161] Fix | Delete
[162] Fix | Delete
""" Tries to determine the libc version that the file executable
[163] Fix | Delete
(which defaults to the Python interpreter) is linked against.
[164] Fix | Delete
[165] Fix | Delete
Returns a tuple of strings (lib,version) which default to the
[166] Fix | Delete
given parameters in case the lookup fails.
[167] Fix | Delete
[168] Fix | Delete
Note that the function has intimate knowledge of how different
[169] Fix | Delete
libc versions add symbols to the executable and thus is probably
[170] Fix | Delete
only useable for executables compiled using gcc.
[171] Fix | Delete
[172] Fix | Delete
The file is read and scanned in chunks of chunksize bytes.
[173] Fix | Delete
[174] Fix | Delete
"""
[175] Fix | Delete
if executable is None:
[176] Fix | Delete
try:
[177] Fix | Delete
ver = os.confstr('CS_GNU_LIBC_VERSION')
[178] Fix | Delete
# parse 'glibc 2.28' as ('glibc', '2.28')
[179] Fix | Delete
parts = ver.split(maxsplit=1)
[180] Fix | Delete
if len(parts) == 2:
[181] Fix | Delete
return tuple(parts)
[182] Fix | Delete
except (AttributeError, ValueError, OSError):
[183] Fix | Delete
# os.confstr() or CS_GNU_LIBC_VERSION value not available
[184] Fix | Delete
pass
[185] Fix | Delete
[186] Fix | Delete
executable = sys.executable
[187] Fix | Delete
[188] Fix | Delete
V = _comparable_version
[189] Fix | Delete
if hasattr(os.path, 'realpath'):
[190] Fix | Delete
# Python 2.2 introduced os.path.realpath(); it is used
[191] Fix | Delete
# here to work around problems with Cygwin not being
[192] Fix | Delete
# able to open symlinks for reading
[193] Fix | Delete
executable = os.path.realpath(executable)
[194] Fix | Delete
with open(executable, 'rb') as f:
[195] Fix | Delete
binary = f.read(chunksize)
[196] Fix | Delete
pos = 0
[197] Fix | Delete
while pos < len(binary):
[198] Fix | Delete
if b'libc' in binary or b'GLIBC' in binary:
[199] Fix | Delete
m = _libc_search.search(binary, pos)
[200] Fix | Delete
else:
[201] Fix | Delete
m = None
[202] Fix | Delete
if not m or m.end() == len(binary):
[203] Fix | Delete
chunk = f.read(chunksize)
[204] Fix | Delete
if chunk:
[205] Fix | Delete
binary = binary[max(pos, len(binary) - 1000):] + chunk
[206] Fix | Delete
pos = 0
[207] Fix | Delete
continue
[208] Fix | Delete
if not m:
[209] Fix | Delete
break
[210] Fix | Delete
libcinit, glibc, glibcversion, so, threads, soversion = [
[211] Fix | Delete
s.decode('latin1') if s is not None else s
[212] Fix | Delete
for s in m.groups()]
[213] Fix | Delete
if libcinit and not lib:
[214] Fix | Delete
lib = 'libc'
[215] Fix | Delete
elif glibc:
[216] Fix | Delete
if lib != 'glibc':
[217] Fix | Delete
lib = 'glibc'
[218] Fix | Delete
version = glibcversion
[219] Fix | Delete
elif V(glibcversion) > V(version):
[220] Fix | Delete
version = glibcversion
[221] Fix | Delete
elif so:
[222] Fix | Delete
if lib != 'glibc':
[223] Fix | Delete
lib = 'libc'
[224] Fix | Delete
if soversion and (not version or V(soversion) > V(version)):
[225] Fix | Delete
version = soversion
[226] Fix | Delete
if threads and version[-len(threads):] != threads:
[227] Fix | Delete
version = version + threads
[228] Fix | Delete
pos = m.end()
[229] Fix | Delete
return lib, version
[230] Fix | Delete
[231] Fix | Delete
def _norm_version(version, build=''):
[232] Fix | Delete
[233] Fix | Delete
""" Normalize the version and build strings and return a single
[234] Fix | Delete
version string using the format major.minor.build (or patchlevel).
[235] Fix | Delete
"""
[236] Fix | Delete
l = version.split('.')
[237] Fix | Delete
if build:
[238] Fix | Delete
l.append(build)
[239] Fix | Delete
try:
[240] Fix | Delete
strings = list(map(str, map(int, l)))
[241] Fix | Delete
except ValueError:
[242] Fix | Delete
strings = l
[243] Fix | Delete
version = '.'.join(strings[:3])
[244] Fix | Delete
return version
[245] Fix | Delete
[246] Fix | Delete
_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
[247] Fix | Delete
r'.*'
[248] Fix | Delete
r'\[.* ([\d.]+)\])')
[249] Fix | Delete
[250] Fix | Delete
# Examples of VER command output:
[251] Fix | Delete
#
[252] Fix | Delete
# Windows 2000: Microsoft Windows 2000 [Version 5.00.2195]
[253] Fix | Delete
# Windows XP: Microsoft Windows XP [Version 5.1.2600]
[254] Fix | Delete
# Windows Vista: Microsoft Windows [Version 6.0.6002]
[255] Fix | Delete
#
[256] Fix | Delete
# Note that the "Version" string gets localized on different
[257] Fix | Delete
# Windows versions.
[258] Fix | Delete
[259] Fix | Delete
def _syscmd_ver(system='', release='', version='',
[260] Fix | Delete
[261] Fix | Delete
supported_platforms=('win32', 'win16', 'dos')):
[262] Fix | Delete
[263] Fix | Delete
""" Tries to figure out the OS version used and returns
[264] Fix | Delete
a tuple (system, release, version).
[265] Fix | Delete
[266] Fix | Delete
It uses the "ver" shell command for this which is known
[267] Fix | Delete
to exists on Windows, DOS. XXX Others too ?
[268] Fix | Delete
[269] Fix | Delete
In case this fails, the given parameters are used as
[270] Fix | Delete
defaults.
[271] Fix | Delete
[272] Fix | Delete
"""
[273] Fix | Delete
if sys.platform not in supported_platforms:
[274] Fix | Delete
return system, release, version
[275] Fix | Delete
[276] Fix | Delete
# Try some common cmd strings
[277] Fix | Delete
import subprocess
[278] Fix | Delete
for cmd in ('ver', 'command /c ver', 'cmd /c ver'):
[279] Fix | Delete
try:
[280] Fix | Delete
info = subprocess.check_output(cmd,
[281] Fix | Delete
stdin=subprocess.DEVNULL,
[282] Fix | Delete
stderr=subprocess.DEVNULL,
[283] Fix | Delete
text=True,
[284] Fix | Delete
shell=True)
[285] Fix | Delete
except (OSError, subprocess.CalledProcessError) as why:
[286] Fix | Delete
#print('Command %s failed: %s' % (cmd, why))
[287] Fix | Delete
continue
[288] Fix | Delete
else:
[289] Fix | Delete
break
[290] Fix | Delete
else:
[291] Fix | Delete
return system, release, version
[292] Fix | Delete
[293] Fix | Delete
# Parse the output
[294] Fix | Delete
info = info.strip()
[295] Fix | Delete
m = _ver_output.match(info)
[296] Fix | Delete
if m is not None:
[297] Fix | Delete
system, release, version = m.groups()
[298] Fix | Delete
# Strip trailing dots from version and release
[299] Fix | Delete
if release[-1] == '.':
[300] Fix | Delete
release = release[:-1]
[301] Fix | Delete
if version[-1] == '.':
[302] Fix | Delete
version = version[:-1]
[303] Fix | Delete
# Normalize the version and build strings (eliminating additional
[304] Fix | Delete
# zeros)
[305] Fix | Delete
version = _norm_version(version)
[306] Fix | Delete
return system, release, version
[307] Fix | Delete
[308] Fix | Delete
_WIN32_CLIENT_RELEASES = {
[309] Fix | Delete
(5, 0): "2000",
[310] Fix | Delete
(5, 1): "XP",
[311] Fix | Delete
# Strictly, 5.2 client is XP 64-bit, but platform.py historically
[312] Fix | Delete
# has always called it 2003 Server
[313] Fix | Delete
(5, 2): "2003Server",
[314] Fix | Delete
(5, None): "post2003",
[315] Fix | Delete
[316] Fix | Delete
(6, 0): "Vista",
[317] Fix | Delete
(6, 1): "7",
[318] Fix | Delete
(6, 2): "8",
[319] Fix | Delete
(6, 3): "8.1",
[320] Fix | Delete
(6, None): "post8.1",
[321] Fix | Delete
[322] Fix | Delete
(10, 0): "10",
[323] Fix | Delete
(10, None): "post10",
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
# Server release name lookup will default to client names if necessary
[327] Fix | Delete
_WIN32_SERVER_RELEASES = {
[328] Fix | Delete
(5, 2): "2003Server",
[329] Fix | Delete
[330] Fix | Delete
(6, 0): "2008Server",
[331] Fix | Delete
(6, 1): "2008ServerR2",
[332] Fix | Delete
(6, 2): "2012Server",
[333] Fix | Delete
(6, 3): "2012ServerR2",
[334] Fix | Delete
(6, None): "post2012ServerR2",
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
def win32_is_iot():
[338] Fix | Delete
return win32_edition() in ('IoTUAP', 'NanoServer', 'WindowsCoreHeadless', 'IoTEdgeOS')
[339] Fix | Delete
[340] Fix | Delete
def win32_edition():
[341] Fix | Delete
try:
[342] Fix | Delete
try:
[343] Fix | Delete
import winreg
[344] Fix | Delete
except ImportError:
[345] Fix | Delete
import _winreg as winreg
[346] Fix | Delete
except ImportError:
[347] Fix | Delete
pass
[348] Fix | Delete
else:
[349] Fix | Delete
try:
[350] Fix | Delete
cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
[351] Fix | Delete
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key:
[352] Fix | Delete
return winreg.QueryValueEx(key, 'EditionId')[0]
[353] Fix | Delete
except OSError:
[354] Fix | Delete
pass
[355] Fix | Delete
[356] Fix | Delete
return None
[357] Fix | Delete
[358] Fix | Delete
def win32_ver(release='', version='', csd='', ptype=''):
[359] Fix | Delete
try:
[360] Fix | Delete
from sys import getwindowsversion
[361] Fix | Delete
except ImportError:
[362] Fix | Delete
return release, version, csd, ptype
[363] Fix | Delete
[364] Fix | Delete
winver = getwindowsversion()
[365] Fix | Delete
try:
[366] Fix | Delete
major, minor, build = map(int, _syscmd_ver()[2].split('.'))
[367] Fix | Delete
except ValueError:
[368] Fix | Delete
major, minor, build = winver.platform_version or winver[:3]
[369] Fix | Delete
version = '{0}.{1}.{2}'.format(major, minor, build)
[370] Fix | Delete
[371] Fix | Delete
release = (_WIN32_CLIENT_RELEASES.get((major, minor)) or
[372] Fix | Delete
_WIN32_CLIENT_RELEASES.get((major, None)) or
[373] Fix | Delete
release)
[374] Fix | Delete
[375] Fix | Delete
# getwindowsversion() reflect the compatibility mode Python is
[376] Fix | Delete
# running under, and so the service pack value is only going to be
[377] Fix | Delete
# valid if the versions match.
[378] Fix | Delete
if winver[:2] == (major, minor):
[379] Fix | Delete
try:
[380] Fix | Delete
csd = 'SP{}'.format(winver.service_pack_major)
[381] Fix | Delete
except AttributeError:
[382] Fix | Delete
if csd[:13] == 'Service Pack ':
[383] Fix | Delete
csd = 'SP' + csd[13:]
[384] Fix | Delete
[385] Fix | Delete
# VER_NT_SERVER = 3
[386] Fix | Delete
if getattr(winver, 'product_type', None) == 3:
[387] Fix | Delete
release = (_WIN32_SERVER_RELEASES.get((major, minor)) or
[388] Fix | Delete
_WIN32_SERVER_RELEASES.get((major, None)) or
[389] Fix | Delete
release)
[390] Fix | Delete
[391] Fix | Delete
try:
[392] Fix | Delete
try:
[393] Fix | Delete
import winreg
[394] Fix | Delete
except ImportError:
[395] Fix | Delete
import _winreg as winreg
[396] Fix | Delete
except ImportError:
[397] Fix | Delete
pass
[398] Fix | Delete
else:
[399] Fix | Delete
try:
[400] Fix | Delete
cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
[401] Fix | Delete
with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key:
[402] Fix | Delete
ptype = winreg.QueryValueEx(key, 'CurrentType')[0]
[403] Fix | Delete
except OSError:
[404] Fix | Delete
pass
[405] Fix | Delete
[406] Fix | Delete
return release, version, csd, ptype
[407] Fix | Delete
[408] Fix | Delete
[409] Fix | Delete
def _mac_ver_xml():
[410] Fix | Delete
fn = '/System/Library/CoreServices/SystemVersion.plist'
[411] Fix | Delete
if not os.path.exists(fn):
[412] Fix | Delete
return None
[413] Fix | Delete
[414] Fix | Delete
try:
[415] Fix | Delete
import plistlib
[416] Fix | Delete
except ImportError:
[417] Fix | Delete
return None
[418] Fix | Delete
[419] Fix | Delete
with open(fn, 'rb') as f:
[420] Fix | Delete
pl = plistlib.load(f)
[421] Fix | Delete
release = pl['ProductVersion']
[422] Fix | Delete
versioninfo = ('', '', '')
[423] Fix | Delete
machine = os.uname().machine
[424] Fix | Delete
if machine in ('ppc', 'Power Macintosh'):
[425] Fix | Delete
# Canonical name
[426] Fix | Delete
machine = 'PowerPC'
[427] Fix | Delete
[428] Fix | Delete
return release, versioninfo, machine
[429] Fix | Delete
[430] Fix | Delete
[431] Fix | Delete
def mac_ver(release='', versioninfo=('', '', ''), machine=''):
[432] Fix | Delete
[433] Fix | Delete
""" Get macOS version information and return it as tuple (release,
[434] Fix | Delete
versioninfo, machine) with versioninfo being a tuple (version,
[435] Fix | Delete
dev_stage, non_release_version).
[436] Fix | Delete
[437] Fix | Delete
Entries which cannot be determined are set to the parameter values
[438] Fix | Delete
which default to ''. All tuple entries are strings.
[439] Fix | Delete
"""
[440] Fix | Delete
[441] Fix | Delete
# First try reading the information from an XML file which should
[442] Fix | Delete
# always be present
[443] Fix | Delete
info = _mac_ver_xml()
[444] Fix | Delete
if info is not None:
[445] Fix | Delete
return info
[446] Fix | Delete
[447] Fix | Delete
# If that also doesn't work return the default values
[448] Fix | Delete
return release, versioninfo, machine
[449] Fix | Delete
[450] Fix | Delete
def _java_getprop(name, default):
[451] Fix | Delete
[452] Fix | Delete
from java.lang import System
[453] Fix | Delete
try:
[454] Fix | Delete
value = System.getProperty(name)
[455] Fix | Delete
if value is None:
[456] Fix | Delete
return default
[457] Fix | Delete
return value
[458] Fix | Delete
except AttributeError:
[459] Fix | Delete
return default
[460] Fix | Delete
[461] Fix | Delete
def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):
[462] Fix | Delete
[463] Fix | Delete
""" Version interface for Jython.
[464] Fix | Delete
[465] Fix | Delete
Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being
[466] Fix | Delete
a tuple (vm_name, vm_release, vm_vendor) and osinfo being a
[467] Fix | Delete
tuple (os_name, os_version, os_arch).
[468] Fix | Delete
[469] Fix | Delete
Values which cannot be determined are set to the defaults
[470] Fix | Delete
given as parameters (which all default to '').
[471] Fix | Delete
[472] Fix | Delete
"""
[473] Fix | Delete
# Import the needed APIs
[474] Fix | Delete
try:
[475] Fix | Delete
import java.lang
[476] Fix | Delete
except ImportError:
[477] Fix | Delete
return release, vendor, vminfo, osinfo
[478] Fix | Delete
[479] Fix | Delete
vendor = _java_getprop('java.vendor', vendor)
[480] Fix | Delete
release = _java_getprop('java.version', release)
[481] Fix | Delete
vm_name, vm_release, vm_vendor = vminfo
[482] Fix | Delete
vm_name = _java_getprop('java.vm.name', vm_name)
[483] Fix | Delete
vm_vendor = _java_getprop('java.vm.vendor', vm_vendor)
[484] Fix | Delete
vm_release = _java_getprop('java.vm.version', vm_release)
[485] Fix | Delete
vminfo = vm_name, vm_release, vm_vendor
[486] Fix | Delete
os_name, os_version, os_arch = osinfo
[487] Fix | Delete
os_arch = _java_getprop('java.os.arch', os_arch)
[488] Fix | Delete
os_name = _java_getprop('java.os.name', os_name)
[489] Fix | Delete
os_version = _java_getprop('java.os.version', os_version)
[490] Fix | Delete
osinfo = os_name, os_version, os_arch
[491] Fix | Delete
[492] Fix | Delete
return release, vendor, vminfo, osinfo
[493] Fix | Delete
[494] Fix | Delete
### System name aliasing
[495] Fix | Delete
[496] Fix | Delete
def system_alias(system, release, version):
[497] Fix | Delete
[498] Fix | Delete
""" Returns (system, release, version) aliased to common
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function