Your IP : 18.216.11.230


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/psutil/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/psutil/__pycache__/_common.cpython-311.pyc

�

��bg�q�
�
�dZddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddl	mZddl	mZddl	mZ	dd	l	mZn
#e$rdZYnwxYw	dd
l	mZn
#e$rdZYnwxYwejdkrddlZndZejddkZeejd
����Ze��Zgd�ZejdkZejdkZ ej!�"d��Z#ej!�"d��Z$e$Z%ej!�"d��Z&ej!�"d��Z'ej!�"d��Z(e&pe'pe(Z)ej!�"d��Z*ej!�"d��Z+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3d Z4d!Z5d"Z6d#Z7d$Z8d%Z9d&Z:d'Z;d(Z<d)Z=d*Z>d+Z?d,Z@d-ZAd.ZBd/ZCd0ZDd1ZEe�d2ZFd3ZGdZHn5Gd4�d5ejI��ZJeK���LeJjM��e�d6ZNd7ZOn5Gd8�d9ejI��ZPeK���LePjM��ejQ��ZResd:ZSn"	ejT��ZSn#eU$r	erd;nd:ZSYnwxYwed<gd=���ZVed>gd?���ZWed@gdA���ZXedBgdC���ZYedDgdE���ZZedFgdG���Z[edHgdI���Z\edJgdK���Z]edLgdM���Z^edNgdO���Z_edPgdQ���Z`edRgdS���ZaedTgdU���ZbedVdWdXg��ZcedYgdZ���Zded[d\d]g��Zeed^gd_���Zfed`gda���Zgedbgda���Zhedcgdd���Ziededfdgg��Zjedhdidjg��Zkedkgdl���Zledmdndog��Zmeeegeegfeegegfegegfeegegfegegfeegeegfegeegfegeegfdp�Zne� en�Legegfegegfdq���e�en�Ldregeegfi��Gds�dteo��ZpGdu�dvep��ZqGdw�dxeq��ZrGdy�dzep��ZsGd{�d|ep��Zter-euevew��r	evd}Zxneyevd}��Zxexd~��nd�Zzd�d��Z{d��Z|d��Z}d��Z~d��Ze|d����Z�d��Z�d��Z�d��Z�d�d��Z�d��Z�Gd��d���Z�d��Z�e���Z�e�j�e�_�e�j�e�_�d�Z�d��Z�d��Z�ee�fd��Z�efd��Z�d�d��Z�d��Z�erd��Z�nd��Z�e|ej�fd����Z�d�d��Z�dd�ej�fd��Z�d��Z�dS)�z9Common objects shared by __init__.py and _ps*.py modules.�)�division)�print_functionN)�
namedtuple)�AF_INET)�
SOCK_DGRAM)�SOCK_STREAM)�AF_INET6)�AF_UNIX)��r�PSUTIL_DEBUG)R�FREEBSD�BSD�LINUX�NETBSD�OPENBSD�MACOS�OSX�POSIX�SUNOS�WINDOWS�
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�
STATUS_PARKED�ENCODING�
ENCODING_ERRSr	�pconn�	pcputimes�pctxsw�pgids�pio�pionice�	popenfile�pthread�puids�sconn�	scpustats�sdiskio�	sdiskpart�
sdiskusage�snetio�snicaddr�	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�	open_text�open_binary�cat�bcat�bytes2human�conn_to_ntuple�debug�hilite�term_supports_colors�print_color�posix�nt�linux�darwin)�freebsd�midnightbsd�openbsd�netbsd)�sunos�solaris�aix�running�sleepingz
disk-sleep�stoppedztracing-stop�zombie�deadz	wake-kill�waking�idle�locked�waiting�	suspended�parked�ESTABLISHED�SYN_SENT�SYN_RECV�	FIN_WAIT1�	FIN_WAIT2�	TIME_WAIT�CLOSE�
CLOSE_WAIT�LAST_ACK�LISTEN�CLOSING�NONE��c��eZdZdZdZdZdS)�	NicDuplexr�r�rN)�__name__�
__module__�__qualname__r$r%r&���E/opt/cloudlinux/venv/lib64/python3.11/site-packages/psutil/_common.pyr�r��s �������������r�r�������c��eZdZdZdZdS)�BatteryTimer�r�N)r�r�r��POWER_TIME_UNKNOWN�POWER_TIME_UNLIMITEDr�r�r�r�r��s��������!���r�r��replace�surrogateescaperH)�total�used�free�percent�sin�soutrD)r�r�r�r�rB)�
read_count�write_count�
read_bytes�write_bytes�	read_time�
write_timerC)�device�
mountpoint�fstype�opts�maxfile�maxpathrE)�
bytes_sent�
bytes_recv�packets_sent�packets_recv�errin�errout�dropin�dropoutrI)�name�terminal�host�started�pidr@)�fd�family�type�laddr�raddr�statusr�rF)r��address�netmask�	broadcast�ptprG)�isup�duplex�speed�mtu�flagsrA)�ctx_switches�
interrupts�soft_interrupts�syscalls�scpufreq)�current�min�max�shwtemp)�labelr��high�critical�sbattery)r��secsleft�
power_plugged�sfanr�r�r8)�user�system�
children_user�children_systemr=�pathr�r>)�id�	user_time�system_timer?)�real�	effective�savedr:r;)r�r�r�r�r<�ioclass�valuer9�	voluntary�involuntaryr7)r�r�r�r�r�r��addr�ip�port)�all�tcp�tcp4�udp�udp4�inet�inet4�inet6)�tcp6�udp6�unixc�(�eZdZdZdZd�Zd�Zd�ZdS)�ErrorzQBase exception class. All other psutil exceptions inherit
    from this one.
    �psutilc��tj��}|D],}t||d��}|r|||<�|dkr|dkr|||<�-|S)Nr�r)�collections�OrderedDict�getattr)�self�attrs�infor�r�s     r��	_infodictzError._infodictsc���&�(�(���	#�	#�D��D�$��-�-�E��
#�"��T�
�
�����5�A�:�:�"��T�
���r�c��|�d��}|r5dd�d�|���D����z}nd}d�d�t|dd��|fD����S)	N)r��ppidr�z(%s)�, c�"�g|]\}}|�d|����
S��=r���.0�k�vs   r��
<listcomp>z!Error.__str__.<locals>.<listcomp>+s'��;�;�;�d�a��A�A�A�q�q�!�;�;�;r�� c��g|]}|�|��Sr�r�)r�xs  r�rz!Error.__str__.<locals>.<listcomp>.s��M�M�M�q�1�M��M�M�Mr��msg�)r��join�itemsr��r�r��detailss   r��__str__z
Error.__str__&s����~�~�5�6�6���	��t�y�y�;�;�d�j�j�l�l�;�;�;� =� =�=�G�G��G��x�x�M�M�W�T�5�"�%=�%=�w�$G�M�M�M�N�N�Nr�c��|�d��}d�d�|���D����}d|jj�d|�d�S)N)r�r�r��secondsrr�c�"�g|]\}}|�d|����
Sr�r�r�s   r�rz"Error.__repr__.<locals>.<listcomp>3s'��G�G�G�$�!�Q����1�1�-�G�G�Gr�zpsutil.�(�))r�r	r
�	__class__r�rs   r��__repr__zError.__repr__0sX���~�~�G�H�H���)�)�G�G�$�*�*�,�,�G�G�G�H�H���"&�.�"9�"9�"9�7�7�7�C�Cr�N)r�r�r��__doc__r�r
rr�r�r�r�r�sZ���������J����O�O�O�D�D�D�D�Dr�r�c��eZdZdZdZdd�ZdS)�
NoSuchProcesszXException raised when a process with a certain PID doesn't
    or no longer exists.
    r�Nc�h�t�|��||_||_|pd|_dS)Nzprocess no longer exists�r��__init__r�r�r�r�r�r�rs    r�rzNoSuchProcess.__init__=s3��
���t���������	��4�4����r��NN�r�r�r�rrr�r�r�rr7s9���������J�5�5�5�5�5�5r�rc��eZdZdZdZdd�ZdS)�
ZombieProcessa1Exception raised when querying a zombie process. This is
    raised on macOS, BSD and Solaris only, and not always: depending
    on the query the OS may be able to succeed anyway.
    On Linux all zombie processes are querable (hence this is never
    raised). Windows doesn't have zombie processes.
    r�Nc�`�t�||||��||_|pd|_dS)Nz"PID still exists but it's a zombie)rrr�r)r�r�r�r�rs     r�rzZombieProcess.__init__Ms4�����t�S�$��4�4�4���	��>�>����r��NNNrr�r�r�rrDs9���������J�?�?�?�?�?�?r�rc��eZdZdZdZdd�ZdS)�AccessDeniedz@Exception raised when permission to perform an action is denied.r�Nc�h�t�|��||_||_|pd|_dS)Nrrrs    r�rzAccessDenied.__init__Ws1��
���t���������	��9�"����r�r!rr�r�r�r#r#Ss3������J�J��J������r�r#c��eZdZdZdZdd�ZdS)�TimeoutExpiredzWRaised on Process.wait(timeout) if timeout expires and process
    is still alive.
    r�Nc�x�t�|��||_||_||_d|z|_dS)Nztimeout after %s seconds)r�rrr�r�r)r�rr�r�s    r�rzTimeoutExpired.__init__ds9��
���t������������	�-��7����r�rrr�r�r�r&r&^s9���������J�8�8�8�8�8�8r�r&�execzvdef raise_from(value, from_value):
    try:
        raise value from from_value
    finally:
        value = None
    c��|��Nr�)r��
from_values  r��
raise_fromr,�s���r�c�x�	t|��|zdz}|�t||��}|S#t$rYdSwxYw)z5Calculate percentage usage of 'used' against 'total'.�dNg)�float�round�ZeroDivisionError)r�r��round_�rets    r�rPrP�s\����T�{�{�U�"�c�)������V�$�$�C��
�������s�s����s�+�
9�9c�f���tj�����fd���}�fd�}i�||_|S)a�A 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()
    >>>

    It supports:
     - functions
     - classes (acts as a @singleton)
     - staticmethods
     - classmethods

    It does NOT support:
     - methods
    c���|tt|�������f}	�|S#t$r6	�|i|��x}�|<n"#t$r}t|d���d}~wwxYw|cYSwxYwr*)�	frozenset�sortedr
�KeyError�	Exceptionr,)�args�kwargs�keyr3�err�cache�funs     ��r��wrapperzmemoize.<locals>.wrapper�s�����Y�v�f�l�l�n�n�5�5�6�6�7��	���:����	�	�	�
,�#&�3��#7��#7�#7�7��e�C�j�j���
,�
,�
,� ��d�+�+�+�����
,�����J�J�J�	���s3�;�
A;�
A�A;�
A3�A.�.A3�3A;�:A;c�0������dS)zClear cache.N)�clear)r>s�r��cache_clearzmemoize.<locals>.cache_clear�s���
���
�
�
�
�
r�)�	functools�wrapsrC)r?r@rCr>s`  @r�rMrM�sf����.�_�S���	�	�	�	�	���	������
�E�%�G���Nr�c�n��tj����fd���}d�}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(self)
    >>> foo()
    1
    >>> foo()
    >>> foo()
    >>>
    c�N��	|j�}n�#t$r1	�|��cYS#t$r}t|d���d}~wwxYwt$rN	�|��}n"#t$r}t|d���d}~wwxYw	||j�<n#t$rYnwxYwYnwxYw|Sr*)�_cache�AttributeErrorr9r,r8)r�r3r=r?s   �r�r@z'memoize_when_activated.<locals>.wrapper�s
���	��+�c�"�C�C���	,�	,�	,�
,��s�4�y�y� � � ���
,�
,�
,� ��d�+�+�+�����
,�����	�	�	�
,��c�$�i�i�����
,�
,�
,� ��d�+�+�+�����
,����
�#&���C� � ��!�
�
�
���
������	�����
sv�
�
B"�
)�B"�
A�A�A�B"�A!� B"�!
B�+A;�;B�B"�
B�B"�
B�B"�B�B"�!B"c��i|_dS)zjActivate cache. Expects a Process instance. Cache will be
        stored as a "_cache" instance attribute.N)rH��procs r��cache_activatez.memoize_when_activated.<locals>.cache_activate�s������r�c�.�	|`dS#t$rYdSwxYw)zDeactivate and clear cache.N)rHrIrKs r��cache_deactivatez0memoize_when_activated.<locals>.cache_deactivate�s2��	�������	�	�	��D�D�	���s��
�)rDrErMrO)r?r@rMrOs`   r��memoize_when_activatedrP�sh���4�_�S����������2���
���,�G��/�G���Nr�c���	tj|��}tj|j��S#t$r+}|jt
jt
jfvr�Yd}~dSd}~wwxYw)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
    NF)�os�stat�S_ISREG�st_mode�OSError�errno�EPERM�EACCES)r��str=s   r�rLrLso��
(�
�W�T�]�]���|�B�J�'�'�'�������9���e�l�3�3�3���u�u�u�u�u��������s�/�
A$� A�A$c��	tj|��dS#t$r+}|jtjtjfvr�Yd}~dSd}~wwxYw)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
    TNF)rRrSrVrWrXrY)r�r=s  r�rOrOsb��
�
���
�
�
��t�������9���e�l�3�3�3���u�u�u�u�u��������s��
A
� A�A
c�(�tjrt�dS	tjttj��}t	j|��5|�d��ddd��n#1swxYwYdS#tj$rYdSwxYw)z2Return True if IPv6 is supported on this platform.NF)z::1rT)�socket�has_ipv6r	r�
contextlib�closing�bind�error)�socks r�rQrQs����?��h�.��u���}�X�v�'9�:�:��
�
��
%�
%�	"�	"��I�I�j�!�!�!�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"��t���<�����u�u����s5�8A>�A1�%A>�1A5�5A>�8A5�9A>�>B�Bc��i}d}t}	|�d|��}||krnU|�d||��}||kr2|||�}||dz|�}|r|���}|||<|dz}�r|S)zCParse a C environ block of environment variables into a dictionary.rT�r�r�)r�find�upper)�datar3�pos�WINDOWS_�next_pos�	equal_posr<r�s        r�rNrN-s���
�C�
�C��H���9�9�T�3�'�'���s�?�?���I�I�c�3��1�1�	��s�?�?��s�9�}�%�C���Q��x�/�0�E��
"��i�i�k�k���C��H���l��� �Jr�c�b�t�|S	tj|��S#t$r|cYSwxYw)z�Convert a numeric socket family value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    )�enumr]�
AddressFamily�
ValueError��nums r�rRrRIsH���|��
�	��'��,�,�,���	�	�	��J�J�J�	������.�.c�b�t�|S	tj|��S#t$r|cYSwxYw)zConvert a numeric socket type value to an IntEnum member.
    If it's not a known member, return the numeric value itself.
    )rnr]�
SocketKindrprqs r�rSrSVsH���|��
�	��$�S�)�)�)���	�	�	��J�J�J�	���rsc	�p�|tjtfvr|r	t|�}|r	t|�}|tjkr,|ttfvr|�|t��}nt}t|��}t|��}|�t||||||��St|||||||��S)z2Convert a raw connection tuple to a proper ntuple.)r]rr	r�r�getr rRrSr7r@)r��fam�type_r�r�r��
status_mapr�s        r�rZrZcs���
�v�~�x�(�(�(��	!��%�L�E��	!��%�L�E���"�"�"�s�w��.A�'A�'A�����	�2�2�����
�#�
�
�C��U�#�#�E�
�{��R��e�U�E�6�:�:�:��R��e�U�E�6�3�?�?�?r�c����fd�}|S)z�A decorator which can be used to mark a method as deprecated
    'replcement' is the method name which will be called instead.
    c����|j�d��d��|j��|_tj|����fd���}|S)Nz*() is deprecated and will be removed; use z
() insteadc�h��tj�td���t|���|i|��S)Nr�)�category�
stacklevel)�warnings�warn�DeprecationWarningr�)r�r:r;r�replacements   ��r��innerz/deprecated_method.<locals>.outer.<locals>.inner�s:����M�#�(:�q�I�I�I�I�-�7�4��-�-�t�>�v�>�>�>r�)r�rrDrE)r?r�rr�s  @�r��outerz deprecated_method.<locals>.outerzsc�����L�L�L�+�+�+�'���;���C�K�	���	�	�	?�	?�	?�	?�	?�
�	�	?��r�r�)r�r�s` r�rKrKvs#���
�
�
�
�
��Lr�c�8�eZdZdZd�Zd�Zd�Zd�Zd	d�Zd�Z	dS)
�_WrapNumberszNWatches numbers so that they don't overflow and wrap
    (reset to zero).
    c�`�tj��|_i|_i|_i|_dSr*)�	threading�Lock�lockr>�	reminders�
reminder_keys�r�s r�rz_WrapNumbers.__init__�s-���N�$�$��	���
��������r�c���||jvsJ�||jvsJ�||jvsJ�||j|<tjt
��|j|<tjt��|j|<dSr*)r>r�r�r��defaultdict�int�set)r��
input_dictr�s   r��	_add_dictz_WrapNumbers._add_dict�s}���4�:�%�%�%�%��4�>�)�)�)�)��4�-�-�-�-�-�%��
�4��*�6�s�;�;���t��#.�#:�3�#?�#?���4� � � r�c��|j|}t|�����t|�����z
}|D]4}|j||D]}|j||=�|j||=�5dS)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�r��old_dict�	gone_keys�gone_key�remkeys       r��_remove_dead_remindersz#_WrapNumbers._remove_dead_reminders�s����:�d�#����
�
���(�(�3�z���/@�/@�+A�+A�A�	�!�	3�	3�H��,�T�2�8�<�
1�
1���N�4�(��0�0��"�4�(��2�2�	3�	3r�c��||jvr|�||��|S|�||��|j|}i}|���D]�}||}	||}n#t$r|||<Y�%wxYwg}tt
|����D]�}	||	}
||	}||	f}|
|krA|j||xx|z
cc<|j||�	|��|�
|
|j||z����t|��||<��||j|<|S)zkCache dict and sum numbers which overflow and wrap.
        Return an updated copy of `input_dict`
        )r>r�r�r�r8�range�lenr�r��add�append�tuple)
r�r�r�r��new_dictr<�input_tuple�	old_tuple�bits�i�input_value�	old_valuer�s
             r��runz_WrapNumbers.run�s����t�z�!�!��N�N�:�t�,�,�,����#�#�J��5�5�5��:�d�#�����?�?�$�$�	(�	(�C�$�S�/�K�
�$�S�M�	�	���
�
�
�!,���
���	
�����D��3�{�+�+�,�,�
H�
H��)�!�n��%�a�L�	��q�����*�*��N�4�(��0�0�0�I�=�0�0�0��&�t�,�S�1�5�5�f�=�=�=����K�$�.��*>�v�*F�F�G�G�G�G�!�$�K�K�H�S�M�M�%��
�4���s�&A/�/B�BNc��|j5|�L|j���|j���|j���nQ|j�|d��|j�|d��|j�|d��ddd��dS#1swxYwYdS)z>Clear the internal cache, optionally only for function 'name'.N)r�r>rBr�r��pop)r�r�s  r�rCz_WrapNumbers.cache_clear�s���
�Y�	3�	3��|��
� � �"�"�"���$�$�&�&�&��"�(�(�*�*�*�*��
���t�T�*�*�*���"�"�4��.�.�.��"�&�&�t�T�2�2�2�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3�	3����	3�	3�	3�	3�	3�	3s�B B5�5B9�<B9c�l�|j5|j|j|jfcddd��S#1swxYwYdS)z5Return internal cache dicts as a tuple of 3 elements.N)r�r>r�r�r�s r��
cache_infoz_WrapNumbers.cache_info�s���
�Y�	D�	D��J����0B�C�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D�	D����	D�	D�	D�	D�	D�	Ds�)�-�-r*)
r�r�r�rrr�r�r�rCr�r�r�r�r�r��s��������� � � �@�@�@�	3�	3�	3�%�%�%�N
3�
3�
3�
3�D�D�D�D�Dr�r�c��tj5t�||��cddd��S#1swxYwYdS)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�r�s  r�rTrT�s���


��)�)��w�w�z�4�(�(�)�)�)�)�)�)�)�)�)�)�)�)����)�)�)�)�)�)s�5�9�9i�c�0�t|dt���S)N�rb��	buffering)�open�FILE_READ_BUFFER_SIZE)�fnames r�rVrV�s����t�'<�=�=�=�=r�c��tst|dt���St|dttt���}	t|_n.#t$rYn"t$r|����wxYw|S)z�On Python 3 opens a file in text mode by using fs encoding and
    a proper en/decoding errors handler.
    On Python 2 this is just an alias for open(name, 'rt').
    �rtr�)r��encoding�errors)	�PY3r�r�r5r6�_CHUNK_SIZErIr9�close)r��fobjs  r�rUrUs���
�B��E�4�+@�A�A�A�A�
��t�'<�!�-�9�9�9�D��1������
�
�
��������
�
����
������Ks�A�
A;�A;c�,�|tur9||��5}|���cddd��S#1swxYwYdS	||��5}|���cddd��S#1swxYwYdS#ttf$r|cYSwxYw)z�Read entire file content and return it as a string. File is
    opened in text mode. If specified, `fallback` is the value
    returned in case of error, either if the file does not exist or
    it can't be read().
    N)�_DEFAULT�read�IOErrorrV)r��fallback�_open�fs    r�rWrWs1���8���
�U�5�\�\�	�Q��6�6�8�8�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	�	���u���
 ���v�v�x�x�
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 �
 ����
 �
 �
 �
 �
 �
 ����!�	�	�	��O�O�O�	���sB�6�:�:�A=�A0�#A=�0A4�4A=�7A4�8A=�=B�Bc�0�t||t���S)z,Same as above but opens file in binary mode.)r�r�)rWrV)r�r�s  r�rXrX+s���u�x�{�;�;�;�;r��%(value).1f%(symbol)sc�6�d}i}t|dd���D]\}}d|dzdzz||<�t|dd���D]9}|||kr+t|��||z}|t��zcS�:|t	|d|���zS)z�Used by various scripts. See:
    http://goo.gl/zeJZl

    >>> bytes2human(10000)
    '9.8K'
    >>> bytes2human(100001221)
    '95.4M'
    )	�B�K�M�G�T�P�E�Z�Yr�N�
r)�symbolr�)�	enumerate�reversedr/�locals�dict)�n�format�symbols�prefixr��sr�r�s        r�rYrY0s���<�G�
�F��'�!�"�"�+�&�&�&�&���1��!�a�%�2��%��q�	�	��7�1�2�2�;�'�'�%�%����v�����!�H�H�v�f�~�-�E��F�H�H�$�$�$�$���D���
�!�4�4�4�4�4r�c�0�tjdjS)z+Return updated psutil.PROCFS_PATH constant.r�)�sys�modules�PROCFS_PATHr�r�r��get_procfs_pathr�Ds���;�x� �,�,r�c�D�|�tt���S)N)r�r�)�decoder5r6�r�s r�r�r�Js���x�x��-�x�@�@�@r�c��|Sr*r�r�s r�r�r�Ms���r�c���tjdkrdS	ddl}|���sJ�|���|�d��dksJ�	dS#t$rYdSwxYw)Nr`Tr�colorsF)rRr��curses�isatty�	setupterm�tigetnumr9)�filer�s  r�r]r]Vs���	�w�$����t���
�
�
��{�{�}�}���}����������x�(�(�1�,�,�,�,�,��t�������u�u����s�A	A � 
A.�-A.Fc��t��s|Sg}tddddddddd	�
�	�	}d|d<	||}n?#t$r2td
t	|�����z���wxYw|�|��|r|�d��dd�|���d|�d�S)z*Return an highlighted version of 'string'.�32�91�33�93�34�35�36�37�30)	�green�red�brown�yellow�blue�violet�	lightblue�grey�darkgrey�29Nz#invalid color %r; choose between %s�1z[�;�mz)r]r�r8rp�listr�r�r	)r��color�bold�attrr�s     r�r\r\es����!�!����
�D�
��$�d�4�d���D�4�I�I�I�F��F�4�L�"��u�
�����"�"�"��>���������!�"�"�	"�"����	�K�K����������C�����"%�(�(�4�.�.�.�.�!�!�!�4�4s	�:�<A6c
��t��st||���dStr"tt|||��|���dSddl}d}|jjj}|jjj}tdddd���}||d<	||}nB#t$r5td	|�d
t|�
���������wxYw|r|dkr|dz
}|tjurdnd
}	|j|_||	��}
||
|��	t||���||
|��dS#||
|��wxYw)z$Print a colorized version of string.�r�rN�r�r�)r�r�r�r�zinvalid color z; choose between �i�i����)r]�printrr\�ctypes�windll�Kernel32�GetStdHandle�SetConsoleTextAttributer�r8rprr�r��stderr�c_ulong�restype)r�rrr�r�
DEFAULT_COLORrrr��	handle_id�handles           r�r^r^xs��� �!�!�;�
�a�d�������	�;�
�f�Q��t�$�$�4�0�0�0�0�0�0��
�
�
��
��}�-�:���M�"�:�	 ��A�1�A�a�8�8�8��$��t��	-��5�M�E�E���	-�	-�	-��*����t�F�K�K�M�M�*�*�*�,�-�-�
-�	-�����	�E�Q�J�J��Q�J�E��3�:�-�-�C�C�3�	�%�~�����i�(�(������.�.�.�	;��!�$�����#�#�F�M�:�:�:�:�:��#�#�F�M�:�:�:�:���s�B�?C�D9�9Ec�P�tr�ddl}|�|���j��\}}}}}t|t��r-t|tttf��rd|z}nd|z}td|�d|�d|��tj���dSdS)	z@If PSUTIL_DEBUG env var is set, print a debug message to stderr.rNzignoring %szignoring %rzpsutil-debug [�:z]> r	)
r
�inspect�getframeinfo�currentframe�f_back�
isinstancer9rVr��EnvironmentErrorr
r�r)rrr��lineno�_�lines�indexs       r�r[r[�s���������)0�)=�)=�� � �"�"�)�*+�*+�&��v�q�%���c�9�%�%�	*��#���2B�C�D�D�
*�#�c�)���#�c�)��
��E�E�E�6�6�6�3�3�?��:�	�	�	�	�	�	��r�r*)r�)NF)�r�
__future__rrr�r_rWrDrRr]rSr�r�r�rrrrr	�ImportErrorr
�version_infornr��bool�getenvr
�objectr��__all__r�rr�platform�
startswithrrrrrrrr�AIXr+r,r(r-r/r3r'r1r2r)r*r0r.r4rr"r!rrr#rrrrrr r$r%r&�IntEnumr��globals�update�__members__r�r�r��getfilesystemencodingr5r6�getfilesystemencodeerrorsrIrHrDrBrCrErIr@rFrGrAr�r�r�r�r8r=r>r?r:r;r<r9r7r�rJr9r�rrr#r&r�__builtins__r��exec_r�r,rPrMrPrLrOrQrNrRrSrZrKr�rTr�rCr�r�rVrUrWrXrYr�r��stdoutr]r\r^r[r�r�r��<module>r8s���
@�?�
 ������%�%�%�%�%�%�����������������	�	�	�	�
�
�
�
�����
�
�
�
���������"�"�"�"�"�"���������������������������������H�H�H�������������������G�G�G�������v����K�K�K�K��D�
��q��Q����t�I�B�I�n�-�-�.�.���6�8�8������J	��7���
�'�T�/�������(�(�������)�)����

�,�
!�
!�"<�
=�
=��

�,�
!�
!�)�
,�
,��	��	 �	 ��	*�	*��
�"��"�F������ 4�5�5��	�l���e�$�$������ ����$���
������
����
������
�!���
��
�������
�
����
������	��<��O��O���������D�L����
�G�I�I���Y�*�+�+�+��<������"�"�"�"�"�d�l�"�"�"��G�I�I���[�,�-�-�-�%�3�$�&�&��
�B��M�M�B�5��5�7�7�
�
���B�B�B�-2�A�)�)�	�
�
�
�B����	�
�7�%�%�%�	&�	&���Z��&J�&J�&J�
K�
K�
�
�*�Y�!<�!<�!<�=�=��
�J�{�%;�%;�%;�
<�
<�	�
��H�4�4�4�
5�
5��
	�
�7�J�J�J�K�K���
�7�.�.�.�	/�	/���:�j�J�J�J�L�L��
�J�{�B�B�B�
D�
D�	�
�J��N�N�N�
P�
P�	��:�j�";�";�";�<�<��
�*�
�7�7�7�9�9���:�j�"J�"J�"J�K�K���z�&�7�I�.�/�/��

�J�{�M�M�M�
O�
O�	�
�J�{�V�T�N�3�3�	�
�*�Y� B� B� B�
C�
C���
�7�:�:�:�;�;���
�7�:�:�:�;�;���j��6�6�6�7�7���*�Y��G� 4�
5�
5��	��H�{�M�:�	;�	;���
�7�'�'�'�	(�	(���z�&�4��.�)�)���h��(�;�
�*C�D�
�h��+��/��Y��
�&�
�h��*��.��Y���%��x�
 �;�
�";�<��i�+�z�2�
3��j�;�
�3�
4�	
�	
�	���
�����k�]�+���j�\�*������
��
����'��[�*�5�6�����D�D�D�D�D�I�D�D�D�B
5�
5�
5�
5�
5�E�
5�
5�
5�?�?�?�?�?�M�?�?�?������5����8�8�8�8�8�U�8�8�8�*���z�,��%�%�.��V�$������f�-�-��	�E��	�	�	�	����	�	�	�	�)�)�)�XB�B�B�J(�(�(����	�
�
�	��
����8
�
�
�
�
�
�@�@�@�@�&���$TD�TD�TD�TD�TD�TD�TD�TD�n)�)�)��l�n�n���?����.���"��>�>�>����4!�	�����""�<�<�<�<�
5�5�5�5�(-�-�-�
��A�A�A�A����	�!�j����	���5�5�5�5�(�E��
� ;� ;� ;� ;�F
�
�
�
�
s6�A�A!� A!�%A,�,A6�5A6�I*�*I8�7I8

?>