eaiovnaovbqoebvqoeavibavo B  f @s$dZdZdZddlZddlZddlZddlZddlZddlZy ej Z Wn(e k rnej dkrfdZ ndZ YnXdZ d d d d d d d d ddd ZedZddZedejZejdddfddZddZedejZedejZedejZdZddZddded fd!d"Zd#d$Zdddefd%d&Zdd)d*Zdd+d,Z ed-Z!dd/d0Z"d1d2d3d4d5d6d7d8d9d:d;d< Z#d3d=d>d?d@dAdBZ$ddCdDZ%dEdFZ&ddHdIZ'dJdKZ(ddLdMZ)dNdOZ*dPdQZ+ddRdSZ,dTdUZ-ddVdWZ.ddXdYZ/dZd[d\d.Z0ejddfd]d^Z1e2d_d`Z3da4dadbZ5dcddZ6dedfZ7dgdhZ8didjZ9dkdlZ:dmdnZ;edoejZedrZ?iZ@ddsdtZAdudvZBdwdxZCdydzZDd{d|ZEd}d~ZFddZGddZHiZIdddZ eJdkr dejKkpdejKkZLdejKkodejKkZMeNe eMeLeOddS)a8 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. a Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com Copyright (c) 2000-2010, 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 ! z1.0.8N)doswin32win16ZNULz /dev/nullz/etc (2) ZdevZalphaaZbetabcZRCrcplpz([0-9]+|[._+-])c Csfg}x\t|D]N}|dkryt|d}d}Wn tk rNt|d}YnX|||fqW|S)Nz._+-rdr) _component_resplitint ValueError _ver_stagesgetextend)versionresultvtr-/opt/alt/python37/lib64/python3.7/platform.py_comparable_versions rsC(__libc_init)|(GLIBC_([0-9.]+))|(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)i@c Cst}ttjdrtj|}t|dX}||}d}x@|t|krzd|ksZd|krht ||}nd}|r| t|kr||} | r|t |t|dd| }d}q<|sPdd | D\} } } } }}| r|sd }n| r|d krd }| }n|| ||krp| }n\| rp|d krpd }|rJ|rF||||krJ|}|rp|t| d|krp||}| }qszlibc_ver..Zlibcglibc) rhasattrospathr!openreadlen _libc_searchsearchendmaxgroups) executablelibrZ chunksizeVfZbinaryposmchunkZlibcinitr(Z glibcversionZsoZthreadsZ soversionrrrlibc_versJ     r;c Csptjdrd}td`}xX|D]P}|}t|dkr |\}}nq |dkrV|}q |dkr |d}|d}q WWdQRX|||fStjdrtdD}x<|D]4}|d} t| dkr| d d krd | d |fSqWWdQRXtjd rftd } x:t t| d d d D]"} | | dddkr| | =qW| rf| d}| d dd}|||fS|||fS)z Tries some special tricks to get the distribution information in case the default method fails. Currently supports older SuSE Linux, Caldera OpenLinux and Slackware Linux distributions. z/var/adm/inst-log/infoSuSEZMIN_DIST_VERSIONZ DIST_IDENT-Nz/etc/.installedrZ OpenLinuxz/usr/lib/setupzslack-version- slackware) r*r+existsr,rr.stripisdirlistdirrangesort) distnameridr7lineZtvtagvaluevaluesZpkgZverfilesnrrr_dist_try_harders>               rPz(\w+)[-_](release|version)z'(.+) release ([\d.]+)[^(]*(?:\((.+)\))?z1([^0-9]+)(?: release )?([\d.]+)[^(]*(?:\((.+)\))?)r<ZdebianZfedoraZredhatZcentosZmandrakeZmandrivaZrocksrBZ yellowdogZgentooZ UnitedLinuxZ turbolinuxZarchZmageiacCszd}d}t|}|dk r&t|St|}|dk rDt|S|}|rp|d}t|dkrp|d}d||fS)Nr rr?)_lsb_release_versionmatchtupler3_release_versionrDrr.) firstlinerrJr9lrrr_parse_release_file0s      rWr?cCs(ddl}|jdtddt|||||S)NrzFdist() and linux_distribution() functions are deprecated in Python 3.5r=) stacklevel)warningswarnDeprecationWarning_linux_distribution)rIrrJsupported_distsfull_distribution_namerYrrrlinux_distributionKs   r_c Csytt}Wntk r(|||fSX|xD|D]0}t|}|dk r8|\}} ||kr8|}Pq8Wt|||St tj t|dddd} | } WdQRXt | \}} } |r|r|}| r| }| r| }|||fS)a Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. supported_dists may be given to define the set of Linux distributions to look for. It defaults to a list of currently supported Linux distributions identified by their release file name. If full_distribution_name is true (default), the full distribution read from the OS is returned. Otherwise the short name taken from supported_dists is used. Returns a tuple (distname, version, id) which default to the args given as parameters. Nrzutf-8surrogateescape)encodingerrors)r*rF _UNIXCONFDIROSErrorrH_release_filenamerRr3rPr,r+joinreadlinerW)rIrrJr]r^Zetcfiler9Z _distnameZdummyr7rUZ_versionZ_idrrrr\Us0      r\cCs*ddl}|jdtddt||||ddS)aS Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. Returns a tuple (distname, version, id) which default to the args given as parameters. rNzFdist() and linux_distribution() functions are deprecated in Python 3.5r=)rX)r]r^)rYrZr[r\)rIrrJr]rYrrrdists  rjr`r@cCs&ddl}|jdtddt|||S)z! Portable popen() interface. rNzuse os.popen insteadr=)rX)rYrZr[r*popen)cmdmodebufsizerYrrrrksrkcCsd|d}|r||ytt|}Wntk r>|}YnXttt|}d|dd}|S)z Normalize the version and build strings and return a single version string using the format major.minor.build (or patchlevel). .N)rappendmaprrliststrrg)rbuildrVZintsZstringsrrr _norm_versions   rvz'(?:([\w ]+) ([\w.]+) .*\[.* ([\d.]+)\])rrrc Cstj|kr|||fSxddD]R}y&t|}|}|rBtdWn$tk rh}zwWdd}~XYqXPqW|||fS|}t |}|dk r| \}}}|ddkr|dd}|ddkr|dd}t |}|||fS)a+ 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. XXX Others too ? In case this fails, the given parameters are used as defaults. )Zverzcommand /c verz cmd /c verzcommand failedNr@ro) sysplatformr*rkr-closererD _ver_outputrRr3rv) systemreleaserZsupported_platformsrlpipeinfoZwhyr9rrr _syscmd_vers,           rZ2000ZXPZ 2003ServerZpost2003Vista78z8.1zpost8.1Z10Zpost10) )r)rr?)rr=)rN)r)rr?)rr=)rrp)rN)rr)rNZ 2008ServerZ 2008ServerR2Z 2012ServerZ 2012ServerR2Zpost2012ServerR2))rr=)rr)rr?)rr=)rrp)rNc Csyddlm}Wntk r,||||fSX|}|jpD|dd\}}}d|||}t||fpxt|dfpx|}|dd||fkryd|j}Wn4tk r|dddkrd |dd}YnXt |d ddkr t ||fpt |dfp|}y0y ddl } Wntk r6ddl } YnXWntk rPYnLXy2d } | | j| } | | d d}WdQRXWntk rYnX||||fS) Nr)getwindowsversionrpz {0}.{1}.{2}r=zSP{} z Service Pack ZSPZ product_typez,SOFTWARE\Microsoft\Windows NT\CurrentVersionZ CurrentType)rxr ImportErrorZplatform_versionformat_WIN32_CLIENT_RELEASESrZservice_pack_majorAttributeErrorgetattr_WIN32_SERVER_RELEASESwinreg_winregZ OpenKeyExHKEY_LOCAL_MACHINEZ QueryValueExre) r}rcsdptyperZwinverZmajminrurZcvkeykeyrrr win32_versD rc Csd}tj|sdSy ddl}Wntk r4dSXt|d}||}WdQRX|d}d}tj}|dkrxd}|||fS)Nz0/System/Library/CoreServices/SystemVersion.plistrr"ZProductVersion)r r r )ZppczPower MacintoshZPowerPC) r*r+rCplistlibrr,loadunamemachine)fnrr7rr} versioninforrrr _mac_ver_xmlEs    rr r r cCst}|dk r|S|||fS)a< 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 parameter values which default to ''. All tuple entries are strings. N)r)r}rrrrrrmac_ver[s rcCs@ddlm}y||}|dkr$|S|Stk r:|SXdS)Nr)System) java.langrZ getPropertyr)namedefaultrrMrrr _java_getpropns  rc Csy ddl}Wntk r(||||fSXtd|}td|}|\}}}td|}td|}td|}|||f}|\}} } td| } td |}td | } || | f}||||fS) a] Version interface for Jython. 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 ''). rNz java.vendorz java.versionz java.vm.namezjava.vm.vendorzjava.vm.versionz java.os.archz java.os.namezjava.os.version)rrr) r}vendorvminfoosinfojavaZvm_nameZ vm_releaseZ vm_vendoros_name os_versionos_archrrrjava_verys"              rcCs|dkrd|||fS|dkr|dkr0|||fS|d}|ryt|d}Wntk rbYn X|d}t||d<d|}|dkrd }qd }n,|d krd }|r|d }qd }n |dkrd}|||fS)z 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. ZRhapsodyzMacOS X ServerZSunOS5rorrp6ZSolarisZIRIX64ZIRIXz (64bit)64bit)rrWindows)rrrrtrg)r|r}rrVmajorrrr system_aliass2      rcGsdddtt|D}|dd}|dd}|dd}|dd}|d d}|d d}|d d}|d d}|d d}x|dd}||krP|}qWx|ddkr|dd}qW|S)zq Helper to format the platform string in a filename compatible format e.g. "system-version-machine". r>css|]}|VqdS)N)rD)r%xrrr sz_platform.. _/\:;"()unknownr z--r@N)rgfilterr.replace)argsryZcleanedrrr _platforms$          rcCsDy ddl}Wntk r |SXy|Stk r>|SXdS)z8 Helper to determine the node name of this machine. rN)socketrZ gethostnamere)rrrrr_nodes rcCsFtj|}x4tj|r@tjtjtj|t|}qW|S)zT In case filepath is a symlink, follow it until a real file is reached. )r*r+abspathislinknormpathrgdirnamereadlink)filepathrrr_follow_symlinkss  "rc Csftjdkr|Sytd|tf}Wnttfk r<|SX|}| }|rZ|r^|S|SdS)z. Interface to the system's uname command. )rrrzuname %s 2> %sN) rxryr*rkDEV_NULLrrer-rDrz)Zoptionrr7outputrrrr _syscmd_uname s  rc Csztjdkr|St|}ytjd|gtjtjd}Wnttfk rJ|SX| d d}| }|rn|rr|S|SdS)z Interface to the system's file command. The function uses the -b option of the file command to have it omit the filename in its output. Follow the symlinks. It returns default in case the command should fail. )rrrri)stdoutstderrrzlatin-1N) rxryr subprocessPopenPIPEZSTDOUTrreZ communicater$wait)targetrprocrrrrr _syscmd_files  r)r WindowsPE)r r)r MSDOScCs*|sLddl}y|d}Wn |jk r:|d}YnXt|dd}|r\t|d}nd}|s|tjkrtjtkrttj\}}|r|}|r|}||fSd|kr||fSd |krd }nd |krd }n d |krd}d|krd}n>d|krd|krd}nd}n d|krd}nd|kr"d}n||fS)a 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. rNPrVbitr r4z32-bit32bitZN32Zn32bitz64-bitrZELFZPErrZCOFFzMS-DOSr) structZcalcsizeerrorrtrrxr4ry_default_architecture)r4bitslinkagersizeZfileoutr rVrrr architectureBsL      r uname_resultz-system node release version machine processorcCsd}tdk rtSd}yt\}}}}}Wntk rBd}YnX|sbttd|||||fs|r~tj}d}d}t}d}d}|dkrt \}}}} |r|rd}|sdtj krtj dd}ntj dd}|stj d|}|r:t |\}}}|d krd }n4|d kr:|d kr:d }d |dd kr6d}nd}|dkrd|s^|dkrZd}nd}d }n8|dddkrt \}} } } d}d| }|s| }|dkr|r|dkr|}d}y ddl} Wntk rYn&X| dd\}}|dkrd}nd}|stdd}|dkr$d}|dkr2d}|dkr@d}|dkrNd}|dkr\d}|dkrjd}|d kr|d krd }d}t||||||atS)an Fairly portable uname interface. Returns a tuple of strings (system, node, release, version, machine, processor) identifying the underlying platform. 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 ''. rNr r?rZPROCESSOR_ARCHITEW6432ZPROCESSOR_ARCHITECTUREZPROCESSOR_IDENTIFIERzMicrosoft WindowsrZ Microsoftz6.0rpr)rrrZ16bitrJavaz, ZOpenVMS0zSYI$_CPUZAlphaZVAXz-pr) _uname_cacher*rrrsrrxryrrenvironrrrrgvms_librZgetsyirr)Z no_os_uname processorr|noder}rrZuse_syscmd_verrrrrrrZcsidZ cpu_numberrrrrs                  rcCstjS)z Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'. An empty string is returned if the value cannot be determined. )rr|rrrrr|%sr|cCstjS)z Returns the computer's network name (which may not be fully qualified) An empty string is returned if the value cannot be determined. )rrrrrrr.srcCstjS)z Returns the system's release, e.g. '2.2.0' or 'NT' An empty string is returned if the value cannot be determined. )rr}rrrrr}8sr}cCstjS)z Returns the system's release version, e.g. '#3 on degas' An empty string is returned if the value cannot be determined. )rrrrrrrAsrcCstjS)zt Returns the machine type, e.g. 'i386' An empty string is returned if the value cannot be determined. )rrrrrrrJsrcCstjS)a 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. )rrrrrrrSs rzL([\w.+]+)\s*\(#?([^,]+)(?:,\s*([\w ]*)(?:,\s*([\w :]*))?)?\)\s*\[([^\]]+)\]?z;IronPython\s*([\d\.]+)(?: \(([\d\.]+)\))? on (.NET [\d\.]+)zU([\d.]+)\s*\(IronPython\s*[\d.]+\s*\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)zE([\w.+]+)\s*\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*\[PyPy [^\]]+\]?cCs|dkrtj}t|d}|dk r&|Sd|krd}|drHt|}n t|}|dkrjtdt || \}}}d}d}ntj drd}t |}|dkrtdt || \}}}} } |dkrd}tj }nd|kr"d}t |}|dkr td t || \}}}} d}n\t |}|dkrFtd t || \}}}} }d }|dkrld}n| r~|d | }ttd rtj\} } } n"ttdrtj\} } } nd} d} |d} t| dkr| dd| }||| | |||f}|t|<|S)a Returns a parsed version of Python's sys.version as tuple (name, version, branch, revision, buildno, builddate, compiler) referring to the Python implementation name, version, branch, revision, 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'). The function returns empty strings for tuple entries that cannot be determined. sys_version may be given to parse an alternative version string, e.g. if the version was read from a different Python interpreter. NZ IronPythonz*failed to parse IronPython sys.version: %sr rZJythonz&failed to parse Jython sys.version: %sZPyPyz$failed to parse PyPy sys.version: %sz'failed to parse CPython sys.version: %sZCPythonr_git _mercurialror=r)rxr_sys_version_cacher startswith_ironpython_sys_version_parserrR _ironpython26_sys_version_parserrreprr3ry_sys_version_parser_pypy_sys_version_parserr)rrrr.rqrg) sys_versionrrrRrZ alt_versionZcompilerZbuildnoZ builddateZ buildtimerbranchZrevisionrVrrr _sys_version}sx                      rcCs tdS)aR Returns a string identifying the Python implementation. Currently, the following implementations are identified: 'CPython' (C implementation of Python), 'IronPython' (.NET implementation of Python), 'Jython' (Java implementation of Python), 'PyPy' (Python implementation of Python). r)rrrrrpython_implementations rcCs tdS)z 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). r?)rrrrrpython_versionsrcCsttddS)z 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). r?ro)rSrrrrrrpython_version_tuples rcCs tdS)z Returns a string identifying the Python implementation branch. For CPython this is the SCM branch from which the Python binary was built. If not available, an empty string is returned. r=)rrrrr python_branchs rcCs tdS)z Returns a string identifying the Python implementation revision. For CPython this is the SCM revision from which the Python binary was built. If not available, an empty string is returned. rp)rrrrrpython_revisions rcCstddS)zh Returns a tuple (buildno, builddate) stating the Python build number and date as strings. rr)rrrrr python_build"srcCs tdS)zS Returns a string identifying the compiler used for compiling Python. r)rrrrrpython_compiler*src Cst||fd}|dk r|St\}}}}}}||kr:d}|rPt|||\}}}|dkrt|\} } } } |rxt||} nt|||| } n*|dkr t"tddt t d\}}}WdQRX|r|st||||d|||} n$t t j \}}t||||d||} n|dkrXt\}}}\}}}|s4|sBt|||} nt|||d |||} n\|d kr|rtt||} n t|||} n2|rt||} n tt j \}}t||||||} | t||f<| S) a 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. Nr r)ZLinuxignorez?dist\(\) and linux_distribution\(\) functions are deprecated .*withrZonZMacOS)_platform_cacherrrrrrYcatch_warningsfilterwarningsr[rjr;rxr4rr)aliasedterserr|rr}rrrZrelZversrrryrIZ distversionZdistidZlibcnameZ libcversionr`rrrrrrrrrrry6s\               ry__main__rz--terseZ nonaliasedz --nonaliased)r`r@)r )r r r rw)r r r r )r rr )r r rr)r )r )r )N)rr)P__doc__Z __copyright__ __version__ collectionsrxr*rerrYdevnullrrryrdrcompilerrASCIIr/r4r;rPrfrQrTZ_supported_distsrWr_r\rjrkrvr{rrrrrrrrrrrrrrrr namedtuplerrrr|rr}rrrrrrrrrrrrrrrrr__name__argvrrprintexitrrrr se      :2 6    0 0  #6   T       h      [