3 \W@s>dZdZddlZddlZddlZddlZddlZddlZy ejZ Wn(e k rjej dkrbdZ ndZ YnXd Z d d d d d d ddddd Z ejdZddZejdejZejdddfddZddZejdejZejdejZejdejZdZd-d.Zddded/fd0d1Zd2d3Zdddefd4d5Zdd7d8Zdd9d:Zejd;Z ddiZ?dddZ@ddZAddZBddZCddZDddZEddZFddZGiZHdddZ eIdkr:dejJkp dejJkZKdejJko dejJkZLeMe eLeKejNddS)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.8Ndoswin32win16ZNULz /dev/nullz/etc (2) ZdevZalphaaZbetabcZRCrcplpz([0-9]+|[._+-])c Csfg}x\tj|D]N}|dkryt|d}d}Wn tk rNtj|d}YnX|j||fqW|S)Nz._+-rdr) _component_resplitint ValueError _ver_stagesgetextend)versionresultvtr /usr/lib64/python3.6/platform.py_comparable_versions rsC(__libc_init)|(GLIBC_([0-9.]+))|(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)i@c Cst}ttjdrtjj|}t|d`}|j|}d}xH|t|krd|ksZd|krhtj ||}nd}| s|j t|kr|j|} | r|t |t|dd| }d}q<|sPdd|j D\} } } } }}| r| rd }n| r|d krd }| }n|| ||krx| }n^| rx|d krxd }|rR| sN||||krR|}|rx|t| d|krx||}|j }qszlibc_ver..Zlibcglibc) rhasattrospathr!openreadlen _libc_searchsearchendmaxgroups) executablelibrZ chunksizeVfZbinaryposmchunkZlibcinitr(Z glibcversionZsoZthreadsZ soversionrrrlibc_versJ        r;c Csptjjdrd}td`}xX|D]P}|j}t|dkr |\}}nq |dkrV|j}q |dkr |jd}|d}q WWdQRX|||fStjjdrtdD}x<|D]4}|jd} t| dkr| dd krd | d |fSqWWdQRXtjjd rftjd } x:t t| d ddD]"} | | dd d kr| | =qW| rf| j d}| dd d}|||fS|||fS)Nz/var/adm/inst-log/infoSuSEZMIN_DIST_VERSIONZ DIST_IDENT-z/etc/.installedrZ OpenLinuxz/usr/lib/setupzslack-version- slackwarerBrB) r*r+existsr,rr.stripisdirlistdirrangesort) distnameridr7lineZtvtagvaluevaluesZpkgZverfilesnrrr_dist_try_harders>               rPz(\w+)[-_](release|version)z'(.+) release ([\d.]+)[^(]*(?:\((.+)\))?z1([^0-9]+)(?: release )?([\d.]+)[^(]*(?:\((.+)\))?r<debianfedoraredhatcentosmandrakemandrivarocksrA yellowdoggentoo UnitedLinux turbolinuxarchmageiacCszd}d}tj|}|dk r&t|jStj|}|dk rDt|jS|jj}|rp|d}t|dkrp|d}d||fS)Nr rr?)_lsb_release_versionmatchtupler3_release_versionrDrr.) firstlinerrJr9lrrr_parse_release_file0s      rdr?cCs(ddl}|jdtddt|||||S)NrzFdist() and linux_distribution() functions are deprecated in Python 3.5r=) stacklevel)warningswarnPendingDeprecationWarning_linux_distribution)rIrrJsupported_distsfull_distribution_namerfrrrlinux_distributionKs   rlcCsytjt}Wntk r(|||fSX|jxD|D]0}tj|}|dk r8|j\}} ||kr8|}Pq8Wt|||St tj j t|dddd} | j } WdQRXt | \}} } |r|r|}| r| }| r| }|||fS)Nrzutf-8surrogateescape)encodingerrors)r*rF _UNIXCONFDIROSErrorrH_release_filenamer_r3rPr,r+joinreadlinerd)rIrrJrjrkZetcfiler9Z _distnameZdummyr7rbZ_versionZ_idrrrriUs0      ricCs*ddl}|jdtddt||||ddS)NrzFdist() and linux_distribution() functions are deprecated in Python 3.5r=)re)rjrk)rfrgrhri)rIrrJrjrfrrrdists  rwrmcCs&ddl}|jdtddtj|||S)Nrzuse os.popen insteadr=)re)rfrgDeprecationWarningr*popen)cmdmodebufsizerfrrrrysryc Csd|jd}|r|j|ytt|}Wntk r>|}YnXttt|}dj|dd}|S)N.)rappendmaprrliststrrt)rbuildrcZintsZstringsrrr _norm_versions   rz'(?:([\w ]+) ([\w.]+) .*\[.* ([\d.]+)\])c Cstj|kr|||fSxddD]R}y&tj|}|j}|jrBtdWn$tk rh}zwWYdd}~XqXPqW|||fS|j}tj |}|dk r|j \}}}|ddkr|dd }|d dkr|dd }t |}|||fS) Nvercommand /c ver cmd /c verzcommand failedr?r})rrrrBrBrBrB) sysplatformr*ryr-closerrrD _ver_outputr_r3r) systemreleaserZsupported_platformsrzpipeinfoZwhyr9rrr _syscmd_vers,           rZ2000ZXPr=Z 2003ServerZpost2003Vista78r~z8.1zpost8.1Z10Zpost10Z 2008ServerZ 2008ServerR2Z 2012ServerZ 2012ServerR2Zpost2012ServerR2c(Csyddlm}Wntk r,||||fSXyddlm}m}m}m}Wn,tk rvddlm}m}m}m}YnX|} | j p| dd\} } } dj | | | }t j | | fpt j | dfp|}| dd| | fkr$ydj | j }Wn8tk r"|ddd krd |dd}YnXt| d ddkrZtj | | fpXtj | dfpX|}d} z.y||d } || d d}Wn YnXWd| r|| X||||fS)Nr)getwindowsversion) OpenKeyEx QueryValueExCloseKeyHKEY_LOCAL_MACHINEr~z {0}.{1}.{2}r=zSP{} z Service Pack ZSPZ product_typez,SOFTWARE\Microsoft\Windows NT\CurrentVersionZ CurrentType)rr ImportErrorwinregrrrr_winregZplatform_versionformat_WIN32_CLIENT_RELEASESrZservice_pack_majorAttributeErrorgetattr_WIN32_SERVER_RELEASES)rrcsdptyperrrrrZwinverZmajminrkeyrrr win32_versD  rcCsd}tjj|sdSy ddl}Wntk r4dSXt|d}|j|}WdQRX|d}d }tjj}|d krxd}|||fS) Nz0/System/Library/CoreServices/SystemVersion.plistrr"ZProductVersionr ppcPower MacintoshZPowerPC)r r r )rr) r*r+rCplistlibrr,loadunamemachine)fnrr7rr versioninforrrr _mac_ver_xmlEs    rcCst}|dk r|S|||fS)N)r)rrrrrrrmac_ver[s rc Cs@ddlm}y|j|}|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) Nrz java.vendorz java.versionz java.vm.namezjava.vm.vendorzjava.vm.versionz java.os.archz java.os.namezjava.os.version)rrr) rvendorvminfoosinfojavaZvm_nameZ vm_releaseZ vm_vendoros_name os_versionos_archrrrjava_verys"              rc Cs|dkrd|||fS|dkr|dkr0|||fS|jd}|ryt|d}Wntk rbYn X|d}t||d<dj|}|dkrd }qd }n,|d krd }|r|d }qd }n |dkrd}|||fS)NZRhapsodyzMacOS X ServerZSunOS5r}rr~6ZSolarisZIRIX64ZIRIXz (64bit)64bitrrWindows)rr)rrrrrt)rrrrcmajorrrr system_aliass2      rcGsdjddtt|D}|jdd}|jdd}|jdd}|jdd}|jd d}|jd d}|jd d}|jd d}|jd d}x|jdd}||krP|}qWx|ddkr|dd}qW|S)Nr>css|]}|jVqdS)N)rD)r%xrrr sz_platform.. _/\:;"()unknownr z--r?rBrB)rtfilterr.replace)argsrZcleanedrrr _platforms$          rcCsDy ddl}Wntk r |SXy|jStk r>|SXdS)Nr)socketrZ gethostnamerr)rrrrr_nodes rcCsFtjj|}x4tjj|r@tjjtjjtjj|tj|}qW|S)N)r*r+abspathislinknormpathrtdirnamereadlink)filepathrrr_follow_symlinkss  "rc Cshtjdkr|Sytjd|tf}Wnttfk r<|SX|jj}|j }| s\|r`|S|SdS)Nrrrzuname %s 2> %s)rrr) rrr*ryDEV_NULLrrrr-rDr)Zoptionrr7outputrrrr _syscmd_uname s   rc Cs|tjdkr|St|}ytjd|gtjtjd}Wnttfk rJ|SX|j dj d}|j }| sp|rt|S|SdS) Nrrrrv)stdoutstderrrzlatin-1)rrr) rrr subprocessPopenPIPEZSTDOUTrrrZ communicater$wait)targetrprocrrrrr _syscmd_files   r WindowsPErMSDOS)rrrc Cs.|sLddl}y|jd}Wn |jk r:|jd}YnXt|dd}|r\t|d}nd}| r|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)NrPrcbitr r4z32-bit32bitZN32Zn32bitz64-bitrZELFZPErrZCOFFzMS-DOSr) structZcalcsizeerrorrrrr4r_default_architecture)r4bitslinkagersizeZfileoutr rcrrr architectureBsL       r uname_resultz-system node release version machine processorcCsd}tdk rtSd}ytj\}}}}}Wntk rBd}YnX|sdttd|||||f r|rtj}d}d}t}d}d}|dkrt \}}}} |r|rd}|sdtj krtj j dd}ntj j dd}|stj j d|}|ros      :2 6    0 0  #6   T       k      [