Your IP : 18.224.54.118


Current Path : /usr/lib64/python3.6/site-packages/psutil/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/psutil/__pycache__/_common.cpython-36.pyc

3

��JZ�E�V@s.dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZddlmZydd	lmZWnek
r�dZYnXydd
lmZWnek
r�dZYnXe	jd�k�r�ddlZndZe	jddkZd
ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRgFZejdSkZejdTkZe	jjdU�Ze	jjdV�Ze	jjdW�Z e	jjdX�Z!e	jjdY�Z"e �p�e!�p�e"Z#e	jjdZ��pe	jjd[�Z$e	jjd\�Z%d]Z&d^Z'd_Z(d`Z)daZ*dbZ+dcZ,ddZ-deZ.dfZ/dgZ0dhZ1diZ2djZ3dkZ4dlZ5dmZ6dnZ7doZ8dpZ9dqZ:drZ;dsZ<dtZ=duZ>edk�r�dvZ?dwZ@dZAn Gdxdy�dyejB�ZCeD�jEeCjF�edk�r�d�ZGd�ZHn Gdzd{�d{ejB�ZIeD�jEeIjF�e	jJ�ZKe�s
d|ZLn2ye	jM�ZLWn$eNk
�r:e�r2d}nd|ZLYnXedFd~dd�d�d�d�g�ZOedBd~dd�d�g�ZPed@d�d�d�d�d�d�g�ZQedAd�d�d�d�g�ZRedCd�d�d�d�d�d�d�d�g�ZSedGd�d�d�d�d�g�ZTed>d�d�d�d�d�d�d�g�ZUedDd�d�d�d�d�g�ZVedEd�d�d�d�g�ZWed?d�d�d�d�g�ZXed�d�d�d�g�ZYed�d�d�d�d�g�ZZed�d�d�d�g�Z[ed�d�d�g�Z\ed6d�d�d�d�g�Z]ed;d�d�g�Z^ed<d�d�d�g�Z_ed=d�d�d�g�Z`ed8d�d�d�g�Zaed9d�d�d�d�g�Zbed:d�d�g�Zced7d�d�g�Zded5d�d�d�d�d�d�g�Zeed�d�d�g�Zfeeegeegfeegegfegegfeegegfegegfeegeegfegeegfegeegfd˜Zgedk	�r~egjEegegfegegfd̜�edk	�r�egjEd�egeegfi�[[[[d�d�dN�Zhd�dK�Zid�dфZjd�dJ�Zkd�dM�Zleid�dO��Zmd�dL�Znd�dP�Zod�dQ�Zpd�dI�ZqGd�dڄdڃZrd�dR�Zser�Ztetjues_uetjves_vdS)�z9Common objects shared by __init__.py and _ps*.py modules.�)�divisionN)�defaultdict)�
namedtuple)�AF_INET)�
SOCK_DGRAM)�SOCK_STREAM)�AF_INET6)�AF_UNIX���FREEBSD�BSD�LINUX�NETBSD�OPENBSD�OSX�POSIX�SUNOS�WINDOWS�ENCODING�
ENCODING_ERRSr�
CONN_CLOSE�CONN_CLOSE_WAIT�CONN_CLOSING�CONN_ESTABLISHED�CONN_FIN_WAIT1�CONN_FIN_WAIT2�
CONN_LAST_ACK�CONN_LISTEN�	CONN_NONE�
CONN_SYN_RECV�
CONN_SYN_SENT�CONN_TIME_WAIT�NIC_DUPLEX_FULL�NIC_DUPLEX_HALF�NIC_DUPLEX_UNKNOWN�STATUS_DEAD�STATUS_DISK_SLEEP�STATUS_IDLE�
STATUS_LOCKED�STATUS_RUNNING�STATUS_SLEEPING�STATUS_STOPPED�STATUS_SUSPENDED�STATUS_TRACING_STOP�STATUS_WAITING�STATUS_WAKE_KILL�
STATUS_WAKING�
STATUS_ZOMBIE�pconn�	pcputimes�pctxsw�pgids�pio�pionice�	popenfile�pthread�puids�sconn�	scpustats�sdiskio�	sdiskpart�
sdiskusage�snetio�snic�	snicstats�sswap�suser�	conn_tmap�deprecated_method�
isfile_strict�memoize�parse_environ_block�path_exists_strict�
usage_percent�
supports_ipv6�sockfam_to_enum�socktype_to_enum�wrap_numbers�posix�nt�linux�darwinZfreebsdZopenbsdZnetbsd�sunos�solaris�aixZrunningZsleepingz
disk-sleepZstoppedztracing-stopZzombieZdeadz	wake-killZwakingZidle�lockedZwaitingZ	suspendedZESTABLISHEDZSYN_SENTZSYN_RECVZ	FIN_WAIT1Z	FIN_WAIT2Z	TIME_WAITZCLOSEZ
CLOSE_WAITZLAST_ACKZLISTENZCLOSINGZNONE��c@seZdZdZdZdZdS)�	NicDuplexrYrZrN)�__name__�
__module__�__qualname__r#r$r%�r_r_�/usr/lib64/python3.6/_common.pyr[sr[c@seZdZdZdZdS)�BatteryTimerZrYN������)r\r]r^�POWER_TIME_UNKNOWN�POWER_TIME_UNLIMITEDr_r_r_r`ra�sra�replace�surrogateescape�total�usedZfreeZpercentZsinZsoutZ
read_countZwrite_countZ
read_bytesZwrite_bytesZ	read_timeZ
write_timeZdeviceZ
mountpointZfstypeZoptsZ
bytes_sentZ
bytes_recvZpackets_sentZpackets_recvZerrinZerroutZdropinZdropout�nameZterminal�hostZstarted�pid�fdZfamily�typeZladdrZraddrZstatusZaddressZnetmaskZ	broadcastZptpZisupZduplexZspeedZmtuZctx_switchesZ
interruptsZsoft_interruptsZsyscalls�scpufreqZcurrent�min�max�shwtempZlabelZhighZcritical�sbatteryZsecsleftZ
power_plugged�sfan�user�system�
children_user�children_system�path�idZ	user_timeZsystem_time�realZ	effectiveZsavedZioclass�valueZ	voluntaryZinvoluntary�addrZipZport)�allZtcpZtcp4ZudpZudp4ZinetZinet4Zinet6)Ztcp6Zudp6ZunixcCs\y||d}Wn0tk
r@t|t�s4t|t�r8dnd}YnX|dk	rTt||�S|SdS)z5Calculate percentage usage of 'used' against 'total'.�dgrN)�ZeroDivisionError�
isinstance�float�round)rirhZ_round�retr_r_r`rLs"
cs2tj����fdd��}�fdd�}i�||_|S)aA simple memoize decorator for functions supporting (hashable)
    positional arguments.
    It also provides a cache_clear() function for clearing the cache:

    >>> @memoize
    ... def foo()
    ...     return 1
        ...
    >>> foo()
    1
    >>> foo.cache_clear()
    >>>
    csH|tt|j���f}y�|Stk
rB�||�}�|<|SXdS)N)�	frozenset�sorted�items�KeyError)�args�kwargs�keyr�)�cache�funr_r`�wrapper"szmemoize.<locals>.wrappercs�j�dS)zClear cache.N)�clearr_)r�r_r`�cache_clear+szmemoize.<locals>.cache_clear)�	functools�wrapsr�)r�r�r�r_)r�r�r`rIs
	csNtj�����fdd����fdd�}��fdd�}i�d�_|�_|�_�S)a�A memoize decorator which is disabled by default. It can be
    activated and deactivated on request.
    For efficiency reasons it can be used only against class methods
    accepting no arguments.

    >>> class Foo:
    ...     @memoize
    ...     def foo()
    ...         print(1)
    ...
    >>> f = Foo()
    >>> # deactivated (default)
    >>> foo()
    1
    >>> foo()
    1
    >>>
    >>> # activated
    >>> foo.cache_activate()
    >>> foo()
    1
    >>> foo()
    >>> foo()
    >>>
    csH�js�|�Sy��}Wn$tk
r>�|�}��<YnX|SdS)N)�cache_activatedr�)�selfr�)r�r�r�r_r`r�Nsz'memoize_when_activated.<locals>.wrappercs
d�_dS)zActivate cache.TN)r�r_)r�r_r`�cache_activateYsz.memoize_when_activated.<locals>.cache_activatecsd�_�j�dS)zDeactivate and clear cache.FN)r�r�r_)r�r�r_r`�cache_deactivate]sz0memoize_when_activated.<locals>.cache_deactivateF)r�r�r�r�r�)r�r�r�r_)r�r�r�r`�memoize_when_activated4sr�cCsTytj|�}Wn4tk
rB}z|jtjtjfkr4�dSd}~XnXtj|j�SdS)z�Same as os.path.isfile() but does not swallow EACCES / EPERM
    exceptions, see:
    http://mail.python.org/pipermail/python-dev/2012-June/120787.html
    FN)�os�stat�OSError�errno�EPERM�EACCES�S_ISREG�st_mode)ry�st�errr_r_r`rHiscCsLytj|�Wn4tk
rB}z|jtjtjfkr4�dSd}~XnXdSdS)z�Same as os.path.exists() but does not swallow EACCES / EPERM
    exceptions, see:
    http://mail.python.org/pipermail/python-dev/2012-June/120787.html
    FNT)r�r�r�r�r�r�)ryr�r_r_r`rKxscCsbtjstdkrdSy2tjttj�}tj|��|jd�WdQRXdStjk
r\dSXdS)z2Return True if IPv6 is supported on this platform.NF�::1rT)r�r)�socketZhas_ipv6rr�
contextlib�closingZbind�error)Zsockr_r_r`rM�scCszi}d}t}xh|jd|�}||kr$P|jd||�}||krj|||�}||d|�}|rb|j�}|||<|d}qW|S)zCParse a C environ block of environment variables into a dictionary.r��=rZ)r�find�upper)�datar��posZWINDOWS_Znext_posZ	equal_posr�r|r_r_r`rJ�s cCs4tdkr|Sy
tj|�Sttfk
r.|SXdS)z�Convert a numeric socket family value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    N)�enumr�Z
AddressFamily�
ValueError�AttributeError)�numr_r_r`rN�s
cCs4tdkr|Sy
tj|�Sttfk
r.|SXdS)zConvert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    N)r�r�ZAddressTyper�r�)r�r_r_r`rO�s
cs�fdd�}|S)z�A decorator which can be used to mark a method as deprecated
    'replcement' is the method name which will be called instead.
    cs:d|j�f�|jdkr�|_tj|���fdd��}|S)Nz8%s() is deprecated and will be removed; use %s() insteadcs tj�tdd�t|��||�S)NrY)�category�
stacklevel)�warnings�warn�
FutureWarning�getattr)r�r�r�)�msg�replacementr_r`�inner�sz/deprecated_method.<locals>.outer.<locals>.inner)r\�__doc__r�r�)r�r�)r�)r�r`�outer�s
z deprecated_method.<locals>.outerr_)r�r�r_)r�r`rG�sc@sBeZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	d
S)�_WrapNumberszNWatches numbers so that they don't overflow and wrap
    (reset to zero).
    cCs tj�|_i|_i|_i|_dS)N)�	threadingZLock�lockr��	reminders�
reminder_keys)r�r_r_r`�__init__�s
z_WrapNumbers.__init__cCsT||jkst�||jkst�||jks*t�||j|<tt�|j|<tt�|j|<dS)N)r��AssertionErrorr�r�r�int�set)r��
input_dictrjr_r_r`�	_add_dict�s
z_WrapNumbers._add_dictcCsd|j|}t|j��t|j��}x<|D]4}x"|j||D]}|j||=q<W|j||=q(WdS)z�In case the number of keys changed between calls (e.g. a
        disk disappears) this removes the entry from self.reminders.
        N)r�r��keysr�r�)r�r�rj�old_dictZ	gone_keysZgone_key�remkeyr_r_r`�_remove_dead_reminders�s

z#_WrapNumbers._remove_dead_remindersc
Cs||jkr|j||�|S|j||�|j|}i}x�|j�D]�}||}y||}Wntk
rt|||<w>YnXg}xvtt|��D]f}	||	}
||	}||	f}|
|kr�|j|||7<|j||j	|�|j
|
|j||�q�Wt|�||<q>W||j|<|S)zkCache dict and sum numbers which overflow and wrap.
        Return an updated copy of `input_dict`
        )r�r�r�r�r��range�lenr�r��add�append�tuple)
r�r�rjr�Znew_dictr�Zinput_tupleZ	old_tuple�bits�iZinput_valueZ	old_valuer�r_r_r`�run�s2


z_WrapNumbers.runNc
Csh|j�X|dkr0|jj�|jj�|jj�n*|jj|d�|jj|d�|jj|d�WdQRXdS)z>Clear the internal cache, optionally only for function 'name'.N)r�r�r�r�r��pop)r�rjr_r_r`r�"s

z_WrapNumbers.cache_clearc
Cs"|j�|j|j|jfSQRXdS)z5Return internal cache dicts as a tuple of 3 elements.N)r�r�r�r�)r�r_r_r`�
cache_info.sz_WrapNumbers.cache_info)N)
r\r]r^r�r�r�r�r�r�r�r_r_r_r`r��s'
r�c
Cstj�tj||�SQRXdS)z�Given an `input_dict` and a function `name`, adjust the numbers
    which "wrap" (restart from zero) across different calls by adding
    "old value" to "new value" and return an updated dict.
    N)�_wnr�r�)r�rjr_r_r`rP4s)r
rrbrc)N)wr�Z
__future__rr�r�r�r�r�r��sysr�r��collectionsrrrrrr�ImportErrorr	�version_infor�ZPY3�__all__rjrr�platform�
startswithrrrrrr
rZAIXr*r+r'r,r.r2r&r0r1r(r)r/r-rr!r rrr"rrrrrrr#r$r%�IntEnumr[�globals�update�__members__rdrera�getfilesystemencodingrr�getfilesystemencodeerrorsr�rDr@r>r?rArEr<rBrCr=rorrrsrtr4r9r:r;r6r7r8r5r3r}rFrLrIr�rHrKrMrJrNrOrGr�rPr�r�r�r_r_r_r`�<module>sH


	

	






	





 5

W	

?>