3 ̪e;9@s\dZddlZddlZddlZddlZddlZddlZddlZddddddd d d d d dddddddgZej ddkZ e Z e re ZeZeZeZeZdd Zdd Zn eZeZeZeZdd Zdd Ze reZneZe e dfddZe reZeZeZeZeZeZnddlZefddZ e e!ddZe e!ddZe e!d dZe e!d!dZe e!d"dZe e!d#dZej"d$krye#ej$d%Wn6ek rYn"e#k rd&Z%e&e%YnXydd'lm'Z'Wne(k rxydd(l)m*Z*Wn"e(k rdd(l+m*Z*YnXej,d)d*d+d,d-gZ-Gd.d/d/e.Z/e fe0e ee1e2dfe3e4e2e5fd0d1Z6d@d4d Z'YnXydd5l7m8Z8Wn,e(k rej9ej:Bdfd6d Z8YnXydd7l7m;Z;Wn e(k rdBd:d Z;YnXydd;lWn&e(k r GdYnXydd>lm?Z?Wn$e(k rVej@d?dZ?YnXdS)CzModule which provides compatibility with older Python versions. This is more future-compatible rather than the opposite (prefer latest Python 3 way of doing things). NPY3longrangesuperunicode basestringub lru_cachewhichget_terminal_sizeredirect_stderrFileNotFoundErrorPermissionErrorProcessLookupErrorInterruptedErrorChildProcessErrorFileExistsErrorcCs|S)N)srr:/usr/local/lib64/python3.6/site-packages/psutil/_compat.pyr2scCs |jdS)Nzlatin-1)encode)rrrrr 5scCs t|dS)NZunicode_escape)r)rrrrr>scCs|S)Nr)rrrrr Asc)Cst|tkrXtj|}y|j|jjd}Wn$ttfk rNd}t|YnXy |j }WnFt tfk ry |j j }Wn t k rd}t|YnXYnXx|D]}x|j j D]}yXxRt|tjst|tr|j}qy |j}Wqt k r |j||}YqXqWWnt tfk r0wYnX|j|jkrPqWqPqWd}t||tk rlt||St|S)zuLike Python 3 builtin super(). If called without any arguments it attempts to infer them at runtime. rz'super() used in a function with no argsz$super() used in a non-newstyle classzsuper() called outside a method) _SENTINELsys _getframef_localsf_code co_varnames IndexErrorKeyError RuntimeError__mro__AttributeError __class____dict__values isinstancetypes FunctionTypepropertyfget__func____get__ TypeError func_code_builtin_super)type_Z type_or_objZ framedepthfmsgmromethrrrrPsH          csfdd}|S)Ncs*Gfdddj_j_S)Ncs2eZdZfddZGfdddeZZS)zE_instance_checking_exception..wrapped..TemporaryClasscsht|dkrRt|drR|d}x@t|D] }|jds,t||t||q,Wnt|j||dS)Nrr__)lenr(dir startswithsetattrgetattrr__init__)selfargskwargsZ unwrap_meattr)TemporaryClassr%rrr=s  zN_instance_checking_exception..wrapped..TemporaryClass.__init__cs eZdZfddZddZdS)zS_instance_checking_exception..wrapped..TemporaryClass.__metaclass__cs|S)Nr)clsinst)instance_checkerrr__instancecheck__sze_instance_checking_exception..wrapped..TemporaryClass.__metaclass__.__instancecheck__cSstjd}t||S)Nr)rexc_infor()rCZ classinfovaluerrr__subclasscheck__s ze_instance_checking_exception..wrapped..TemporaryClass.__metaclass__.__subclasscheck__N)__name__ __module__ __qualname__rFrIr)rErr __metaclass__s rM)rJrKrLr=typerM __classcell__r)rBrE)r%rrBs rB)rJ__doc__)rE)base_exception)rBrErwrappedsz-_instance_checking_exception..wrappedr)rQrRr)rQr_instance_checking_exceptions rScCst|dttjkS)Nerrno)r<rrTENOENT)rDrrrrscCst|dttjkS)NrT)r<rrTZESRCH)rDrrrrscCst|dttjtjfkS)NrT)r<rrTEACCESEPERM)rDrrrrscCst|dttjkS)NrT)r<rrTZEINTR)rDrrrrscCst|dttjkS)NrT)r<rrTZECHILD)rDrrrrscCst|dttjkS)NrT)r<rrTEEXIST)rDrrrrsCPythonZpermzbbroken or incompatible Python implementation, see: https://github.com/giampaolo/psutil/issues/1659)r )RLock CacheInfohitsmissesmaxsizecurrsizec@s$eZdZdZefddZddZdS) _HashedSeq hashvaluecCs||dd<|||_dS)N)ra)r>tuphashrrrr=s z_HashedSeq.__init__cCs|jS)N)ra)r>rrr__hash__sz_HashedSeq.__hash__N)ra)rJrKrL __slots__rcr=rdrrrrr`s r`c s|} |r2||j} | |7} x| D] } | | 7} q"W|rp| |fdd|D7} |r| |fdd| D7} n$|| dkr| d|kr| dSt| S)Nc3s|]}|VqdS)Nr).0v)rNrr sz_make_key..c3s|]\}}|VqdS)Nr)rfkrg)rNrrrhsrr)itemsr`) r?kwdstypedkwd_mark fasttypessortedtuplerNr8keyZ sorted_itemsitemr)rNr _make_keys    rsdFcsfdd}|S)zLeast-recently-used cache decorator, see: http://docs.python.org/3/library/functools.html#functools.lru_cache. csiddg d \t jtt g ddg dd< g d\dkrl fdd}nPdkr f dd}n*  fdd}  fd d } fd d }|_||_||_tj|S)Nrrrcs||}d7<|S)Nrr)r?rkresult)MISSESstats user_functionrrwrapper s z7lru_cache..decorating_function..wrappercsX||}|}|k r2d7<|S||}||<d7<|S)Nrr)r?rkrqrv) HITSrwcache cache_getmake_keyrootrxrlryrrrz's   c sl|sr ||}n|} jzr|}|dk r \}|\}}}}||<||<|}||<|<||<||< d7<|SWd jX||} jz \}|krn kr|} || <|| <| } d<|} d|<|<| =| |<n,|}||||g}||<|<|< d7<Wd jX|S)Nrr)acquirerelease) r?rkrqlinkrZ link_prevZ link_nextrvlastZoldrootZoldkey)r{KEYrwNEXTPREVRESULT_lenr|r}lockr~r^ nonlocal_rootrxrlryrrrz4sN      c s2jzttSjXdS)zReport cache statistics.N)r _CacheInfor8rr)r{rwr|rr^rxrr cache_infoas z:lru_cache..decorating_function..cache_infoc sPjz8jd}||ddg|dd<ddgdd<WdjXdS)z%Clear the cache and cache statistics.rN)rclearr)r)r|rrrxrr cache_clearksz;lru_cache..decorating_function..cache_clear)rr)rrrur) rsgetr8rZ __wrapped__rr functoolsupdate_wrapper)ryrzrr)r^rl)r{rrwrrrrr|r}rr~rrrxryrdecorating_functions,  *-  z&lru_cache..decorating_functionr)r^rlrr)r^rlrr si)r c s"dd}tjjr&||r"SdS|dkr>tjjdtj}|sFdS|jtj}tj dkrtj |krt|j dtj tjjddjtj}t fd d |Drg}q‡fd d |D}ng}t }xT|D]L}tjj|}||kr|j|x(|D] } tjj|| } || |r| SqWqWdS) aJGiven a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path. cSs&tjj|o$tj||o$tjj| S)N)ospathexistsaccessisdir)fnmoderrr _access_checks  zwhich.._access_checkNPATHwin32rPATHEXTc3s |]}jj|jVqdS)N)lowerendswith)rfext)cmdrrrhszwhich..csg|] }|qSrr)rfr)rrr szwhich..)rrdirnameenvironrdefpathsplitpathseprplatformcurdirinsertanysetnormcaseaddjoin) rrrrpathextfilesseenr9normdirthefilenamer)rrr s8            )r PcCstyddl}ddl}ddl}Wntk r0|SXy(|jd|jd|jd}|d|dfStk rn|SXdS)NrZhhrZ1234)fcntlstructtermios ImportErrorunpackZioctlZ TIOCGWINSZ Exception)fallbackrrrresrrrr s )TimeoutExpiredc@s eZdZdS)SubprocessTimeoutExpiredN)rJrKrLrrrrrsr)r c cs$tj}z|t_|VWd|t_XdS)N)rstderr) new_targetoriginalrrrr s  )rtFrr)r)ArP collections contextlibrTrrrr)__all__ version_inforobjectrintrrxrangestrrrrr rr1rrrrrrrrrSEnvironmentErrorpython_implementationOSErrorrXr4r"r r threadingrZdummy_threading namedtuplerlistr`r frozensetrNrorpr8rsshutilr F_OKX_OKr subprocessrrr contextmanagerrrrrs    ;   r5