[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.226.159.94: ~ $
�

2�Dg����>�dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZddlmZddlZddlmZddlmZdd	lmZdd
lm Z ddlm!Z!ddlm"Z"dd
lm#Z#ddl$m%Z%ddl$m&Z&ddl$m'Z'ddl(m)Z)ddl(m*Z*ddl(m+Z+ddl(m,Z,ddl(m-Z-ddl(m.Z.ddl(m/Z/ddl(m0Z0e+rddl1Z1nddl2Z1	ddl1m3Z3nF#e4$r>ej5��5ej6d��ddl3Z3ddd��n#1swxYwYYnwxYwej7dkrddl8Z8ndZ8gd�Z9dej:vZ;de
j<vZ=de
j<vpd e
j<vZ>e=pe>Z?ej@d!kZAd"ZBd#ZCd$ZDd%ZEe?reBd&zZBeEd&zZEeCd&zZCeDd&zZDe
jFd'krd(e
jG��zZHnd)e
jG��zZHe.d*��ZIe+rd+�Jd,d-��ZKnd.ZKejL���M��d/vZNe
jO�Pe
jO�Qe
jO�ReS��d0d0����ZTe
jO�QeTd1��ZUe
jO�Pe
jO�ReS����ZVe!oe"ZWeXejYd2��ZZeXed3��Z[eXed4��Z\eXejYd5��Z]eXejYd6��Z^eXejYd7��Z_eXed8��Z`eXejYd9��ZaeXejYd:��ZbeXejYd;��ZceXed<��Zd	edoeeejf����Zgn
#eh$rd=ZgYnwxYweXed>��ZieXed?��ZjeXejYd@��Zke seoe
jl��dkZmdA�Znen��Zoepe
jqdB��Zrejserjt��dC�eue��D��ZvewedDex����Zyez��Z{ez��Z|GdE�dFej}��Z~dG�Zed�dH���Z�edI���Z�dJ�Z�edK���Z�edL���Z�ej�eEfdM�Z�d�dN�Z�dO�Z�dP�Z�GdQ�dRex��Z�e�ej�deEdS�T��dU���Z�e�e*e�fdeEdS�T��d�dW���Z�e�e�deEdS�T��dX���Z�dY�Z�dZ�Z�ej�d[���Z�d�d\�Z�d�d^�Z�Gd_�d`e1j���Z�e�e1_�Gda�dbe���Z�e1j�e;dc��Gdd�dee�����Z�df�Z�dg�Z�Gdh�di��Z�Gdj�dk��Z�dl�Z�eBfdm�Z�d�dn�Z�d�do�Z�d�dq�Z�eedfdr�Z�ejfds�Z�d�du�Z�dv�Z�ej�dw���Z�dx�Z�dy�Z�dz�Z�d{�Z�d|�Z�d}�Z�e!rej�d�d~���Z�nej�d�d���Z�ejsd����Z�e!rejej�d����dSdS)�z
Test utilities.
�)�print_functionN)�AF_INET)�AF_INET6)�SOCK_STREAM)�AIX)�FREEBSD)�LINUX)�MACOS)�POSIX)�SUNOS)�WINDOWS)�bytes2human)�print_color)�
supports_ipv6)�FileExistsError)�FileNotFoundError)�PY3)�range)�super)�u)�unicode)�which)�mock�ignore���)E�APPVEYOR�DEVNULL�GLOBAL_TIMEOUT�TOLERANCE_SYS_MEM�
NO_RETRIES�PYPY�
PYTHON_EXE�ROOT_DIR�SCRIPTS_DIR�
TESTFN_PREFIX�UNICODE_SUFFIX�INVALID_UNICODE_SUFFIX�
CI_TESTING�VALID_PROC_STATUSES�TOLERANCE_DISK_USAGE�IS_64BIT�HAS_CPU_AFFINITY�HAS_CPU_FREQ�HAS_ENVIRON�HAS_PROC_IO_COUNTERS�
HAS_IONICE�HAS_MEMORY_MAPS�HAS_PROC_CPU_NUM�
HAS_RLIMIT�HAS_SENSORS_BATTERY�HAS_BATTERY�HAS_SENSORS_FANS�HAS_SENSORS_TEMPERATURES�HAS_MEMORY_FULL_INFO�pyrun�	terminate�
reap_children�spawn_testproc�spawn_zombie�spawn_children_pair�ThreadTaskunittest�skip_on_access_denied�skip_on_not_implemented�retry_on_failure�TestMemoryLeak�PsutilTestCase�process_namespace�system_namespace�
print_sysinfo�install_pip�install_test_deps�chdir�safe_rmpath�
create_exe�decode_path�encode_path�
get_testfn�
get_winver�kernel_version�
call_until�wait_for_pid�
wait_for_file�check_net_address�
get_free_port�bind_socket�bind_unix_socket�tcp_socketpair�unix_socketpair�create_sockets�
reload_module�import_module_by_path�warn�copyload_shared_lib�
is_namedtuple�__pypy__r�GITHUB_ACTIONS�CIBUILDWHEELl�
iPi��r�javaz$psutil-%s-z@psutil-%s-u-ƒőősf���utf8�surrogateescapeufÀ€)�asciizus-asciiz..�scripts�cpu_affinity�cpu_freq�
getloadavg�environ�ionice�memory_maps�net_io_counters�cpu_num�io_counters�rlimit�sensors_batteryF�sensors_fans�sensors_temperatures�threadsc��d�}trktr%trtd��ntd��Str)t
j�tj	��Std��Str�|tj	��p�|t
j�tj	����pZ|tdtjdd�z����p-|tj
�������}|std���|St
j�tj	��}t
j�|��s
J|���|S)Nc��	tj|dgtjtj���|S#t$rYdSwxYw)Nz-V)�stdout�stderr)�
subprocess�
check_call�PIPE�	Exception)�exes �w/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/psutil/tests/__init__.py�attemptz_get_py_exe.<locals>.attempt�s_��	��!��d��J�O�J�O�
M�
M�
M�
M�
�J���	�	�	��4�4�	���s�-1�
?�?�pypy3�pypy�pythonzpython%s.%s�z"can't find python exe real abspath)rdr#rrr�os�path�realpath�sys�
executabler
�version_info�psutil�Processr��
ValueError�exists)r�r�s  r��_get_py_exer��sZ��������	#�%(�;�5��>�>�>�e�F�m�m�;�
�	#��7�#�#�C�N�3�3�3���?�?�"�	���G�C�N�#�#�
,��G�B�G�$�$�S�^�4�4�5�5�
,��G�E�-�#�*:�2�A�2�*>�>�?�?�@�@�
,�
�G�F�N�$�$�(�(�*�*�+�+�		�
�	C��A�B�B�B��
��g���s�~�.�.���w�~�~�c�"�"�'�'�C�'�'�"��
�zr+c�b�g|],}|�d���tt|����-S)�STATUS_��
startswith�getattrr���.0�xs  r��
<listcomp>r��sB��3�3�3�a��,�,�y�1�1�3�w�v�q�)�)�3�3�3r��AF_UNIXc�F��eZdZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
�xZS)	�
ThreadTaskz6A thread task which does nothing expect staying alive.c���t�����d|_d|_t	j��|_dS)NF���MbP?)r�__init__�_running�	_interval�	threading�Event�_flag)�self�	__class__s �r�r�zThreadTask.__init__�s:���
����������
�����_�&�&��
�
�
r�c�N�|jj}d||jt|��fzS)Nz<%s running=%s at %#x>)r��__name__r��id)r��names  r��__repr__zThreadTask.__repr__�s&���~�&��'�4����4���*I�I�Ir�c�.�|���|S�N)�start�r�s r��	__enter__zThreadTask.__enter__s���
�
�����r�c�.�|���dSr�)�stop)r��args�kwargss   r��__exit__zThreadTask.__exit__s���	�	�����r�c��|jrtd���tj�|��|j���dS)zStart thread and keep it running until an explicit
        stop() request. Polls for shutdown every 'timeout' seconds.
        zalready startedN)r�r�r��Threadr�r��waitr�s r�r�zThreadTask.startsL���=�	0��.�/�/�/�����t�$�$�$��
�������r�c��d|_|j���|jr"tj|j��|j� dSdS)NT)r�r��set�time�sleepr�r�s r��runzThreadTask.runsW����
��
�������m�	'��J�t�~�&�&�&��m�	'�	'�	'�	'�	'r�c�h�|jstd���d|_|���dS)z8Stop thread execution and and waits until it is stopped.zalready stoppedFN)r�r��joinr�s r�r�zThreadTask.stops3���}�	0��.�/�/�/���
��	�	�����r�)r��
__module__�__qualname__�__doc__r�r�r�r�r�r�r��
__classcell__)r�s@r�r�r��s��������@�@�'�'�'�'�'�J�J�J����������'�'�'�������r�r�c�F��tj����fd���}|S)Nc�P��	�|i|��S#t$rt���wxYwr�)r�r=)r�r��funs  �r��wrapperz&_reap_children_on_err.<locals>.wrapper%sD���	��3��'��'�'�'���	�	�	��O�O�O��	���s��%��	functools�wraps)r�r�s` r��_reap_children_on_errr�$s8����_�S�����������Nr�c���|�dt��|�dt��|�dtj����|�dtj��t
rd}|�d|��|��t
��}	t|��d|z}td	|g}tj
|fi|��}t�|��t|d
d
���t|��nT#t|��wxYwtj
|fi|��}t�|��t|j��|S)a}Creates a python subprocess which does nothing for 60 secs and
    return it as a subprocess.Popen instance.
    If "cmd" is specified that is used instead of python.
    By default stdin and stdout are redirected to /dev/null.
    It also attemps to make sure the process is in a reasonably
    initialized state.
    The process is registered for cleanup on reap_children().
    �stdinr}�cwd�env��
creationflagsNz:from time import sleep;open(r'%s', 'w').close();sleep(60);z-cT��delete�empty)�
setdefaultrr��getcwdrpr
rQrMr$r�Popen�_subprocesses_started�addrVrU�pid)�cmd�kwds�CREATE_NO_WINDOW�testfn�pyline�sprocs      r�r>r>/sf��	�O�O�G�W�%�%�%��O�O�H�g�&�&�&��O�O�E�2�9�;�;�'�'�'��O�O�E�2�:�&�&�&��;�%������)9�:�:�:�
�{�����
	 ������"�$*�+�F��t�V�,�C��$�S�1�1�D�1�1�E�!�%�%�e�,�,�,��&��T�:�:�:�:��������K���������� ��-�-��-�-���!�!�%�(�(�(��U�Y�����Ls
�.AD�D+c��d}ttj�����}	tjdtj�|���dt�d���}trt|d���\}}nt|��\}}tj|j��}tt|dd	�
����}t�|��tj|��}||ft#|��|�t#|��SS#t#|��|�t#|��wwxYw)aCreate a subprocess which creates another one as in:
    A (us) -> B (child) -> C (grandchild).
    Return a (child, grandchild) tuple.
    The 2 processes are fully initialized and will live for 60 secs
    and are registered for cleanup on reap_children().
    N��dirzl            import subprocess, os, sys, time
            s = "import os, time;"
            s += "f = open('z�', 'w');"
            s += "f.write(str(os.getpid()));"
            s += "f.close();"
            s += "time.sleep(60);"
            p = subprocess.Popen([r'z.', '-c', s])
            p.wait()
            r)r�TFr�)rQr�r��textwrap�dedentr��basenamer$r
r;r�r�r��intrV�
_pids_startedr�rM)�tfiler��s�subp�child�grandchild_pid�
grandchilds       r�r@r@Ws@��
�E�
�B�I�K�K�
(�
(�
(�F���O�O��7�#�#�F�+�+�+�+�Z�Z�Z�	9�	
:�	
:���	#����3�3�3�K�D�%�%���(�(�K�D�%���t�x�(�(���]�6�$�e�L�L�L�M�M�����.�)�)�)��^�N�3�3�
��z�"��F��������������	�F���������������s�CD�#D>c�z��tjsJ�t��}tjd|z��}d}t|��}	|�t��t|��\}}|�	��\}}	tj
|���gggt��t|�
d����}t�|��tj|���t#�fd�d��|�f|���|���t'|��|�t'|��SS#|���wxYw#|���t'|��|�t'|��wwxYw)z�Create a zombie process and return a (parent, zombie) process tuple.
    In order to kill the zombie parent must be terminate()d first, then
    zombie must be wait()ed on.
    a        import os, sys, time, socket, contextlib
        child_pid = os.fork()
        if child_pid > 0:
            time.sleep(3000)
        else:
            # this is the zombie process
            s = socket.socket(socket.AF_UNIX)
            with contextlib.closing(s):
                s.connect('%s')
                if sys.version_info < (3, ):
                    pid = str(os.getpid())
                else:
                    pid = bytes(str(os.getpid()), 'ascii')
                s.sendall(pid)
        N�c�,������Sr�)�status)�zombies�r��<lambda>zspawn_zombie.<locals>.<lambda>�s���v�}�}���r�zret == psutil.STATUS_ZOMBIE)r�rrQr�r�rZ�
settimeoutr r;�accept�select�filenor��recvr�r�r�rT�closerM)	�	unix_file�srcr��sock�parent�conn�_�zpidr�s	        @r�r?r?~s����
�<���<����I�
�/������C� 
�E��I�&�&�D������'�'�'��c�
�
�
����+�+�-�-���a�	��M�4�;�;�=�=�/�2�r�>�B�B�B��t�y�y����'�'�D����d�#�#�#��^�D�)�)�F��.�.�.�.�0M�N�N�N��F�#��J�J�L�L�L��
�
�����I��������������	
�J�J�L�L�L�L������
�
�����I���������������s&�AF�BE*� F�*F�F�7F:c��|�dd��|�dd��t��}	t|d��5}|�|��ddd��n#1swxYwYt	t
|jgfi|��}t|j��||fS#t$rt|���wxYw)z�Run python 'src' code string in a separate interpreter.
    Returns a subprocess.Popen instance and the test file where the source
    code was written.
    r}Nr~�wt)r�rQ�open�writer>r$r�rUr�r�rM)rr��srcfile�fr�s     r�r;r;�s
��	�O�O�H�d�#�#�#��O�O�H�d�#�#�#��l�l�G��
�'�4�
 �
 �	�A�
�G�G�C�L�L�L�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��z�1�6�2�;�;�d�;�;���T�X�����g���������G����
����s/�B*�A.�"B*�.A2�2B*�5A2�63B*�*Cc���t|ttf��rdnd}tr|rdnd}|�d|��|�dt
j��|�dt
j��|�dd��|�d	|��tj|fi|��}t�	|��tr|�t�
��\}}n|���\}}|j
dkrt|���|rt|��|�d��r
|dd
�}|S)zUrun cmd in a subprocess and return its output.
    raises RuntimeError on error.
    TFr�r�shellr}r~�universal_newlinesr���timeout�
N���)�
isinstance�strrr
r�rr�r�r�r�r�communicater �
returncode�RuntimeErrorr`�endswith)r�r�r�flags�pr}r~s       r��shr�sN��
�s�S�'�N�3�3�>�D�D��E� �1�U�1�I�I��E��O�O�G�U�#�#�#��O�O�H�j�o�.�.�.��O�O�H�j�o�.�.�.��O�O�(�$�/�/�/��O�O�O�U�+�+�+����%�%��%�%�A����a� � � �
�)����~��>�>��������������|�q����6�"�"�"�
���V����
���t�����������Mr�c�����	�
��trddlm�d��
d�����
fd�}���
fd��	�	�fd�}d�}|}	t|t��ry|||��t|t
jtjf��r||��t|t��r|n|j}tj	|��r
J|���St|tj
tjf��ry�	||��t|t
jtjf��r||��t|t��r|n|j}tj	|��r
J|���St|t
j��ry|||��t|t
jtjf��r||��t|t��r|n|j}tj	|��r
J|���Std	|z���#t|t
jtjf��r||��t|t��r|n|j}tj	|��r
J|���wxYw)
a�Terminate a process and wait() for it.
    Process can be a PID or an instance of psutil.Process(),
    subprocess.Popen() or psutil.Popen().
    If it's a subprocess.Popen() or psutil.Popen() instance also closes
    its stdin / stdout / stderr fds.
    PID is wait()ed even if the process is already gone (kills zombies).
    Does nothing if the process does not exist.
    Return process exit status.
    r)�wait_pidc�h�t|tj��rts|���n|�|��t
r]t|tj��rE	t
j|j���|��S#tj	$rYdSwxYwdSdSr�)
rrr�rr�r
r�r�r��
NoSuchProcess)�procrs  r�r�zterminate.<locals>.wait�s����d�J�,�-�-�	�c�	��I�I�K�K�K�K��I�I�g�����	�z�$�
�(8�9�9�	�
��~�d�h�/�/�4�4�W�=�=�=���'�
�
�
����
����		�	�	�	s�.+B�B-�,B-c���trtrtj}tr/|tjkr|�tj��|�|��dSr�)r
rd�signal�SIGKILLr�send_signal�SIGCONT)r!�sigs  r��sendsigzterminate.<locals>.sendsig�s^���	!�^�	!��.�C��	-�S�F�N�*�*����V�^�,�,�,���������r�c���	�|���n@#t$r3}tr|jdkrn|jtjkr�Yd}~nd}~wwxYw�||��S)N�)�OSErrorr
�winerror�errno�ESRCH)r!r�errr(r'r�s   ���r��term_subproczterminate.<locals>.term_subproc�s~���	��G�D�#�������	�	�	��
�3�<�1�,�,����e�k�)�)�����������		����
�t�D�'�"�"�"s��
A
�)A�A
c�b��	�|���n#tj$rYnwxYw�||��Sr�)r�r )r!rr(r'r�s  ���r��term_psproczterminate.<locals>.term_psprocsR���	��G�D�#�������#�	�	�	��D�	�����t�D�'�"�"�"s��"�"c���	tj|��}�||��S#tj$rtr�||��cYSYdSwxYwr�)r�r�r r)r�rr!r2rs   ��r��term_pidzterminate.<locals>.term_pidsz���	.��>�#�&�&�D��;�t�W�-�-�-���#�	.�	.�	.��
.��x��W�-�-�-�-�-�
.�
.�
.�	.���s�#�"A�
Ac���|jr|j���|jr|j���|jr|j���dSdSr�)r}r�r~r�)r!s r��flush_popenzterminate.<locals>.flush_popensl���;�	 ��K�������;�	 ��K�������:�	��J��������	�	r�z
wrong type %r)r�psutil._psposixrrr�rr�r�r��
pid_existsr��	TypeError)�proc_or_pidr'�wait_timeoutr0r4r6rr�r(r2r�rs `      @@@@r�r<r<�s��������
�-�,�,�,�,�,�,�
�
�
����#�#�#�#�#�#�#�#�#�#�#�#�#�#�.�.�.�.�.�.����	�A�
/��a����	1��8�A�|�,�,��a�*�*�F�L�9�:�:�	��K��N�N�N��a��%�%�0�a�a�1�5���$�S�)�)�.�.�3�.�.�)�.���F�N�F�L�9�
:�
:�	1��;�q�,�/�/��a�*�*�F�L�9�:�:�	��K��N�N�N��a��%�%�0�a�a�1�5���$�S�)�)�.�.�3�.�.�)�.���:�+�
,�
,�	1��<��<�0�0��a�*�*�F�L�9�:�:�	��K��N�N�N��a��%�%�0�a�a�1�5���$�S�)�)�.�.�3�.�.�)�.��O�a�/�0�0�0���a�*�*�F�L�9�:�:�	��K��N�N�N��a��%�%�0�a�a�1�5���$�S�)�)�.�.�3�.�.�)�)�)�)�)s� H�1H� %H�3H�A/I4c��tj���|���}tr/t���}t|��t�/tr/t���}t|��t�/|rf|D]}t|d����tj|t���\}}|D]1}td|z��t|tj����0dSdS)aTerminate and wait() any subprocess started by this test suite
    and any children currently running, ensuring that no processes stick
    around to hog resources.
    If resursive is True it also tries to terminate and wait()
    all grandchildren started by this process.
    ��	recursiveN)r;rz0couldn't terminate process %r; attempting kill())r')r�r��childrenr��popr<r��
wait_procsr r`r#r$)r>r?r�r�r�gone�alives       r�r=r=3s���~���(�(�9�(�=�=�H� ��$�(�(�*�*���$���� ��
�����!�!���#������
�-��	,�	,�A��a�d�+�+�+�+�+��'��.�I�I�I���e��	-�	-�A��C�a�G�H�H�H��a�V�^�,�,�,�,�,�
-�-�	-�	-r�c���tstd���d}tj��d}|D]"}|���s|dkr||z
}�"|std|z���d}d}|�d��}t|d��}t|��dkrt|d��}t|��dkrt|d��}|||fS)	z"Return a tuple such as (2, 6, 36).z	not POSIX�r��.zcan't parse %rr�r)	r�NotImplementedErrorr��uname�isdigitr��splitr��len)r�rI�c�minor�micro�nums�majors       r�rSrSXs����/�!�+�.�.�.�
�A��H�J�J�q�M�E�
�����9�9�;�;�	�!�s�(�(�
��F�A�A���3��)�E�1�2�2�2�
�E�
�E��7�7�3�<�<�D���Q��L�L�E�
�4�y�y�A�~�~��D��G����
�4�y�y�A�~�~��D��G�����5�%� � r�c�.�tstd���tj��}t	|d��r
|jpd}nBt
jd|d��}|r#t|�	d����}nd}|d|d|fS)Nznot WINDOWS�service_pack_majorrz\s\d$rrG)
r
rHr��getwindowsversion�hasattrrS�re�searchr��group)�wv�sp�rs   r�rRrRps����1�!�-�0�0�0�	�	�	 �	 �B��r�'�(�(��
�
"�
'�a����I�h��1��&�&���	��Q�W�W�Q�Z�Z���B�B��B��q�E�2�a�5�"��r�c�6�eZdZdZeddddfd�Zd�Zd�Zd�ZdS)�retryzA retry decorator.Nr�c�r�|r|rtd���||_||_||_||_||_dS)Nz/timeout and retries args are mutually exclusive)r��	exceptionr�retries�interval�logfun)r�r_rr`rarbs      r�r�zretry.__init__�sK���	P�w�	P��N�O�O�O�"��������� ��
�����r�c#�
K�|jrQtj��|jz}tj��|krdV�tj��|k�dSdS|jrt|j��D]}dV��dS	dV��r�)rr�r`r)r��stop_atrs   r��__iter__zretry.__iter__�s������<�		��i�k�k�D�L�0�G��)�+�+��'�'������)�+�+��'�'�'�'�'�'�
�\�	��4�<�(�(�
�
�������
�
�
�����
r�c�J�|j�tj|j��dSdSr�)rar�r�r�s r�r�zretry.sleep�s*���=�$��J�t�}�%�%�%�%�%�%�$r�c�X���tj�����fd���}�|_|S)Nc����d}�D]U}	�|i|��cS#�j$r<}|}�j���|������Yd}~�Nd}~wwxYwtr|��r�)r_rbr�r)r�r��excrr�r�s    ��r�r�zretry.__call__.<locals>.wrapper�s�����C��
�
����3��/��/�/�/�/�/���~�����C��{�.����C�(�(�(��J�J�L�L�L��H�H�H�H����������
��	�s��
A�2A�A)r�r��	decorator)r�r�r�s`` r��__call__zretry.__call__�sF����	���	�	�	�	�	�	�	�
�	�	�$!����r�)	r�r�r�r�r�r�rer�rk�r�r�r]r]�sl��������%�����
�
�
�
�
�
�
�&�&�&�����r�r]r�)r_rbrrac�h�tj|��trtjd��dSdS)z�Wait for pid to show up in the process list then return.
    Used in the test suite to give time the sub process to initialize.
    �{�G�z�?N)r�r�r
r�r�)r�s r�rUrU�s<���N�3�������
�4�������r�Tc��t|d��5}|���}ddd��n#1swxYwY|s|sJ�|rt|��|S)z8Wait for a file to be written on disk with some content.�rbN)r	�readrM)�fnamer�r�r�datas     r�rVrV�s���
�e�T�	�	��a��v�v�x�x�������������������������t�
���E�����Ks�2�6�6c�<�|��}t|��sJ�|S)zVKeep calling function for timeout secs and exit if eval()
    expression is True.
    )�eval)r��expr�rets   r�rTrT�s%���#�%�%�C���:�:���:��Jr�c�D�d�}	tj|��}tj|j��r t	jtj|��}nt	jtj|��}tr|��dS||��dS#t$rYdSwxYw)z>Convenience function for removing temporary test files or dirsc�\�tj��tz}tj��|kry	|��S#t$rYn7t$r+}|}t	dt|��z��Yd}~nd}~wwxYwtjd��tj��|k�y|�)Nzignoring %srn)r�r r�WindowsErrorr`rr�)r�rdrr/s    r��	retry_funzsafe_rmpath.<locals>.retry_fun�s���
�)�+�+��.���i�k�k�G�#�#�
1��s�u�u���$�
�
�
����
1�
1�
1����]�c�#�h�h�/�0�0�0�0�0�0�0�0�����
1����
�J�t�����i�k�k�G�#�#��	s�	>�
A>�
	A>�!A9�9A>N)r��stat�S_ISDIR�st_moder��partial�shutil�rmtree�removerr)r�r{�str�s    r�rMrM�s������"
�
�W�T�]�]���<��
�#�#�	5��#�F�M�4�8�8�C�C��#�B�I�t�4�4�C��	��C�E�E�E�E�E��I�c�N�N�N�N�N���
�
�
����
���s�A=B�B�
B�Bc�R�	tj|��dS#t$rYdSwxYw)z-Convenience function for creating a directoryN)r��mkdirrr�s r��
safe_mkdirr�s:��
�
���
�
�
�
�
���
�
�
����
���s��
&�&c#�K�tj��}	tj|��dV�tj|��dS#tj|��wxYw)z@Context manager which temporarily changes the current directory.N)r�r�rL)�dirname�curdirs  r�rLrLs]�����Y�[�[�F��
������
����
������������������s�A�Ac��tj�|��r
J|���|r�td��st	d���t|t��rtjd��}t|t��s
J|���ttd���d��5}|�|��ddd��n#1swxYwY	tjd|jd|g��t!|j��dS#t!|j��wxYwt#jt&|��t(r=tj|��}tj||jt*jz��dSdS)	z1Creates an executable file in the given location.�gcczgcc is not installedz�
                #include <unistd.h>
                int main() {
                    pause();
                    return 1;
                }
                z.c��suffixrNz-o)r�r�r�rr�r�boolr�r�rr	rQr
rr�r�rMr��copyfiler$rr|�chmodr~�S_IEXEC)�outpath�c_coderr�s    r�rNrNs����w�~�~�g�&�&�/�/��/�/�&�
�9��U�|�|�	5��3�4�4�4��f�d�#�#�	��_����F��&�#�&�&�.�.��.�.�&�
�*�D�)�)�)�4�
0�
0�	�A�
�G�G�F�O�O�O�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	 ��!�5�!�&�$��"@�A�A�A����������K����������	��
�G�,�,�,��	9����!�!�B��H�W�b�j�4�<�7�8�8�8�8�8�	9�	9s�0C�C�C�D�D'rEc��	tjt||���}tj�|��stj�|��S�[)z�Return an absolute pathname of a file or dir that did not
    exist at the time this call is made. Also schedule it for safe
    deletion at interpreter exit. It's technically racy but probably
    not really due to the time variant.
    T)�prefixr�r�)�tempfile�mktempr'r�r�r�r�)r�r�r�s   r�rQrQ9sN��*���m�F��L�L�L���w�~�~�d�#�#�	*��7�#�#�D�)�)�)�*r�c�\�eZdZd�Zeejd��sejjZe	sd�Z
dSdS)�TestCasec��|jj}|�d��sd|z}|�d|jj�d|j��S)Nzpsutil.z
psutil.tests.rF)r�r�r�r��_testMethodName)r��fqmods  r��__str__zTestCase.__str__NsT����)�����	�*�*�	,�#�e�+�E��E�E�4�>�*�*�*�D�,@�,@�B�	Br��assertRaisesRegexc��dSr�rlr�s r��runTestzTestCase.runTest\s���Dr�N)r�r�r�r�rU�unittestr��assertRaisesRegexpr�rr�rlr�r�r�r�Jsp������B�B�B��7�8�$�&9�:�:�A�$�-�@����	�	�	�	�	��r�r�c�8�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd	�Z	dS)rFzUTest class providing auto-cleanup wrappers on top of process
    test utilities.
    rENc�^�t||���}|�t|��|S)N)r�r�)rQ�
addCleanuprM)r�r�r�rrs    r�rQzPsutilTestCase.get_testfnis-���&�c�2�2�2������U�+�+�+��r�c�T�t|i|��}|�t|��|Sr�)r>r�r<)r�r�r�r�s    r�r>zPsutilTestCase.spawn_testprocns-����-��-�-�����	�5�)�)�)��r�c��t��\}}|�t|��|�t|��||fSr�)r@r�r<)r��child1�child2s   r�r@z"PsutilTestCase.spawn_children_pairssD��,�.�.�������	�6�*�*�*����	�6�*�*�*����r�c��t��\}}|�t|��|�t|��||fSr�)r?r�r<)r�rr�s   r�r?zPsutilTestCase.spawn_zombieysB��%���������	�6�*�*�*����	�6�*�*�*����r�c��t|i|��\}}|�t|��|�t|��|Sr�)r;r�rMr<)r�r�r�r�rs     r�r;zPsutilTestCase.pyrunsE����-��-�-���w�����W�-�-�-����	�5�)�)�)��r�c�*�|�tjtj|j��t|tjtjf��rh|���rJ�	|���}td|z���#tj$rYnwxYw|�
d���tj|j��rJ|j���|�|jtj
����dS)Nz3Process.status() didn't raise exception (status=%s)rr)�assertRaisesr�r r�r�rr��
is_runningr��AssertionErrorr�r8�assertNotIn�pids)r�r!r�s   r��assertProcessGonez PsutilTestCase.assertProcessGone�s�����&�.�����I�I�I��d�V�^�V�\�:�;�;�		!����(�(�(�(�(�
=�������%�&3�5;�&<�=�=�=���'�
�
�
���
����

�I�I�a�I� � � ��$�T�X�.�.�8�8���8�8�.������6�;�=�=�1�1�1�1�1s�.B�B&�%B&�rEN)
r�r�r�r�rQr>r@r?r;r�rlr�r�rFrFds}������������
���
 � � � � � ����
2�
2�
2�
2�
2r�rFzunreliable on PYPYc��eZdZdZdZdZdZerdndZdZ	e
j��Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
�Z		dd�Zd�ZdS)rEa�Test framework class for detecting function memory leaks,
    typically functions implemented in C which forgot to free() memory
    from the heap. It does so by checking whether the process memory
    usage increased before and after calling the function many times.

    Note that this is hard (probably impossible) to do reliably, due
    to how the OS handles memory, the GC and so on (memory can even
    decrease!). In order to avoid false positives, in case of failure
    (mem > 0) we retry the test for up to 5 times, increasing call
    repetitions each time. If the memory keeps increasing then it's a
    failure.

    If available (Linux, OSX, Windows), USS memory is used for comparison,
    since it's supposed to be more precise, see:
    https://gmpy.dev/blog/2016/real-process-memory-and-environ-in-python
    If not, RSS memory is used. mallinfo() on Linux and _heapwalk() on
    Windows may give even more precision, but at the moment are not
    implemented.

    PyPy appears to be completely unstable for this framework, probably
    because of its JIT, so tests on PYPY are skipped.

    Usage:

        class TestLeaks(psutil.tests.TestMemoryLeak):

            def test_fun(self):
                self.execute(some_function)
    ��rfrrgTc�`�|j���}t|d|j��S)N�uss)�	_thisproc�memory_full_infor��rss)r��mems  r��_get_memzTestMemoryLeak._get_mem�s+���n�-�-�/�/���s�E�3�7�+�+�+r�c�t�tr|j���S|j���Sr�)rr��num_fds�num_handlesr�s r��_get_num_fdszTestMemoryLeak._get_num_fds�s2���	0��>�)�)�+�+�+��>�-�-�/�/�/r�c�P�|jrt|dtj���dSdS)N�yellow)�color�file)�verboserr�r~)r��msgs  r��_logzTestMemoryLeak._log�s3���<�	>���8�#�*�=�=�=�=�=�=�	>�	>r�c�<�|���}|�|��|���}||z
}|dkr|�d|z���|dkr5trdnd}|dkr|dz
}|�d|�d|��}|�|���d	S)
z�Makes sure num_fds() (POSIX) or num_handles() (Windows) does
        not increase after calling a function.  Used to discover forgotten
        close(2) and CloseHandle syscalls.
        rzHnegative diff %r (gc probably collected a resource from a previous test)�fd�handlerGr�z
 unclosed z after calling N)r��call�failr)r�r��before�after�diff�type_r�s       r��
_check_fdszTestMemoryLeak._check_fds�s���
�"�"�$�$���	�	�#�����!�!�#�#���v�~���!�8�8��)�)�=�?C�D�E�E�
E��!�8�8�!�/�D�D�x�E��a�x�x�����7;�t�t�U�U�U�C�C�H�C��)�)�C�.�.� ��8r�c�F�tjd���|���}t|��D]}|�|��}~~�tjd���|���}|�tjg��||z
}|S)z�Get 2 distinct memory samples, before and after having
        called fun repeadetly, and return the memory difference.
        rG)�
generation)�gc�collectr�rr��assertEqual�garbage)r�r��times�mem1r�rw�mem2r�s        r��_call_ntimeszTestMemoryLeak._call_ntimes�s���	�
�a� � � � ��}�}�����u���	�	�A��)�)�C�.�.�C��3�3�
�
�a� � � � ��}�}���������R�(�(�(��d�{���r�c
���g}d}|}td|dz��D]�}	|�||��}
d|	�dt|
���dt|
|z���d|��}|�|��|
|kp|
|k}|r|	dkr|�|��dS|	dkrt��|�|��||z
}|
}��|�d�|�����)NrrGzRun #z: extra-mem=z, per-call=z, calls=z. )rr�r�appendr��printr�r�)
r�r�r��warmup_timesr`�	tolerance�messages�prev_mem�increase�idxr�r��successs
             r��
_check_memzTestMemoryLeak._check_mem�s����������G�a�K�(�(�	�	�C��#�#�C��/�/�C�C����[��%�%�%�%�{�3��;�'?�'?�'?�'?���H�C��O�O�C� � � ��Y�&�9�#��/�G��	
���7�7��I�I�c�N�N�N�����!�8�8��G�G�G��	�	�#������!������i�i��	�	�(�+�+�,�,�,r�c��|��Sr�rl)r�r�s  r�r�zTestMemoryLeak.calls
���s�u�u�r�Nc���|�|n|j}|�|n|j}|�|n|j}|�|n|j}	|dks
Jd���|dks
Jd���|dks
Jd���|dks
Jd���n.#t$r!}tt
|�����d}~wwxYw|�||��|�|��|�	|||||���dS)	zTest a callable.NrGztimes must be >= 1rzwarmup_times must be >= 0zretries must be >= 0ztolerance must be >= 0)r�r�r`r�)
r�r�r`r�r�r�rr�r�r�)r�r�r�r�r`r�r/s       r��executezTestMemoryLeak.execute	s3���*����
��'3�'?�|�|��"�	�$�0�'�'�d�l��!*�!6�I�I�D�N�	�	'��A�:�:�:�3�:�:�:��1�$�$�$�&A�$�$�$��a�<�<�<�!7�<�<�<���>�>�>�#;�>�>�>�>���	'�	'�	'��S��X�X�&�&�&�����	'����	
���#�|�,�,�,������������5�|� '�9�	�	>�	>�	>�	>�	>s�AA/�/
B�9B�Bc�6�������fd�}�j|fi|��dS)znConvenience method to test a callable while making sure it
        raises an exception on every call.
        c�4��������dSr�)r�)rir�r�s���r�r�z*TestMemoryLeak.execute_w_exc.<locals>.call"s������c�3�'�'�'�'�'r�N)r�)r�rir�r�r�s```  r��
execute_w_exczTestMemoryLeak.execute_w_excsJ�����	(�	(�	(�	(�	(�	(�	(�	���T�$�$�V�$�$�$�$�$r�)NNNN)r�r�r�r�r�r�r�r*r`r�r�r�r�r�r�r�r�r�r�r�r�r�rlr�r�rErE�s���������<
�E��L��I��%�b�b�A�G��G���� � �I�,�,�,�0�0�0�>�>�>�!�!�!�&
�
�
�-�-�-�0���CG��>�>�>�>�*%�%�%�%�%r�rEc��ddl}ddl}ddl}ddl}ddl}ddl}	ddl}n#t$rd}YnwxYw	ddl}n#t$rd}YnwxYw|�	��}tjr"td��rtd��|d<n�tjr!d|���dz|d<n�tjrvdd�t%t&|�������z|d<t+|d��r%|dxxd	|���zz
cc<n.|����d|�����|d<d	�t3|�����|���gz��|d
<tjr|���d|d<d	�|���|���|� ��g��|d
<tC|dd��|d<|�|dxxd|j"zz
cc<tjrrtd��r=tddg��}	t'|	���#d��d|d<nd|d<|�$��d}
|
r|
|d<tKj&��|d<|�'��}|d�d	|d��|d<|j�(tj)�����*d��|d<|j�+���*d��|d<|�,��|d<tZj.�/d��|d<t[j0��|d<tb|d <|�2��|d!<t[j3��|d"<tj4��|d#<d$tkd%�tj6��D����z|d&<tj7��}tq|j9���d'tu|j;���d(tu|j<����|d)<tj=��}
tq|
j9���d'tu|
j;���d(tu|
j<����|d*<t}tj?����|d+<tj@���A��}|�Bd,d��|�C|��|d-<t�d.tJjE�/��|�F��D])\}}t�|d0zd1�d|��tJjE�/���*t�d.tJjE�/��tJjG�H��dS)2Nr�lsb_releasezlsb_release -d -s�OSz	Darwin %szWindows � �
win32_editionz, �archr��kernelr��__version__z
not installed�pipz (wheel=%s)r�z	--versionrrG�glibczfs-encoding�langz%Y-%m-%d %H:%M:%Sz	boot-timer��user�~�homer��pyexe�hostname�PID�cpusz%.1f%%, %.1f%%, %.1f%%c�@�g|]}|tj��zdz��S)�d)r��	cpu_countr�s  r�r�z!print_sysinfo.<locals>.<listcomp>ps+��I�I�I��q�6�#�%�%�%��+�I�I�Ir��loadavgz%, used=z, total=�memory�swapr�rrr!zF======================================================================�r��:�17)I�collections�datetime�getpass�locale�platform�pprintr��ImportError�wheel�OrderedDictr�r	rr�OSX�mac_verr
r��mapr�	win32_verrUr��system�version�list�architecture�machinerrI�python_implementation�python_version�python_compilerr�r�rK�libc_verr��getfilesystemencoding�	getlocale�
fromtimestamp�	boot_time�strftime�now�getuserr�r��
expanduserr�r$�node�getpidr�tuplero�virtual_memoryr��percentr�used�total�swap_memoryrLr�r��as_dictr@�pformatr�r~�itemsr}�flush)rr	r
rrr
r�r�info�outr�r�r�r�pinfo�k�vs                 r�rIrI(s��������O�O�O��N�N�N��M�M�M��O�O�O��M�M�M���
�
�
�
����������������������������������"�"�$�$�D��|�
G��m�,�,�
G��+�,�,��T�
�
�	��G� �8�#3�#3�#5�#5�a�#8�8��T�
�
�	��G��#�(�(���X�'�'�)�)�*�*�#,�#,�,��T�
��8�_�-�-�	:���J�J�J�$��!7�!7�!9�!9�9�9�J�J�J�� (��� 1� 1� 1� 1�8�3C�3C�3E�3E�3E�F��T�
��9�9��X�
"�
"�
$�
$�%�%��)9�)9�);�);�(<�<�>�>�D��L�
�|�-�!���)�)�!�,��X���Y�Y��&�&�(�(����!�!�� � �"�"� $�%�%�D��N��#�}�o�>�>�D��K����U����}�u�'8�8�8�����|����<�<�	*��e�[�)�*�*�C��c�(�(�.�.��.�.�q�1�D��K�K�)�D��K�������"���	��D��M��3�5�5�D��������D�#�A�w�w�w��Q���0�D��L� �)�7�7�������$�H�%8�9�9�	����$�(�(�*�*�3�3�4G�H�H�D��L��?�?�$�$�D��L��7�%�%�c�*�*�D��L��)�+�+�D��K��D��M��}�}���D����)�+�+�D��K��#�%�%�D��L�.�
�I�I�V�5F�5H�5H�I�I�I�J�J�L�D��O�
�
�
!�
!�C��C�K�����+�c�h�/�/�/�/��S�Y�1G�1G�1G�I�D��N�����D��D�L�����;�t�y�1�1�1�1�;�t�z�3J�3J�3J�L�D��L��v�{�}�}�%�%�D��L��N���$�$�&�&�E�	�I�I�m�T�"�"�"��>�>�%�(�(�D��L�	�(���$�$�$�$��
�
���:�:���1�
�A��G�G�G�G�Q�Q�'�c�j�9�9�9�9�9�	�(���$�$�$�$��J�������s��.�.�7�A�Ac���tj��}t|d��r|���St|d��r&t	j|�����SdS)Nrtrmr)r�r�rUrt�random�choicerm)rs r��_get_eligible_cpur:�s`������A��q�)���/��y�y�{�{��	��N�	#�	#�/��}�Q�^�^�-�-�.�.�.��1r�c��eZdZdZddifddifgZddifddddifd	difd
difddifddifd
difddifddifg	Zddifddddifddifddifddifddifddifddifddifddifddifddifddifd difd!difd"difd#difgZer$ed$difgz
Zed%difgz
Zed&difgz
Zed'difgz
Zer	ed(difgz
Ze	r	ed)difgz
Ze
red*ejfifgz
Ze
r	ed+difgz
Zer	ed,difgz
Zer	ed-difgz
Zer	ed.difgz
Zered/dd0d1ifgz
ZgZer
eddifgz
Znedejfifgz
Ze
red*ejd2fifgz
Ze	r"ered)ejd3fifgz
Zned)ejfifgz
Ze
red+e��gfifgz
Zd4ejfifd5difd6difd7difd8difgZered4ejfifgz
Zed4ejfifgz
ZeezezezZd9�Zd?d:�Zd;�Z e!d<���Z"e!d=���Z#d>S)@rGaA container that lists all Process class method names + some
    reasonable parameters to be called with. Utility methods (parent(),
    children(), ...) are excluded.

    >>> ns = process_namespace(psutil.Process())
    >>> for fun, name in ns.iter(ns.getters):
    ...    fun()
    �cpu_percentrl�memory_percentr.r?r>Tr��memory_info_ex�oneshotr�parentsr�r��r�cmdline�connections�kind�all�	cpu_times�create_timer�r�r��memory_infor��nice�num_ctx_switches�num_threads�
open_files�ppidr�rz�username�uids�gids�terminalr�rurqrvrmrtrpr�rr�groupedF)r�irr%�suspend�resumer<�killc��||_dSr�)�_proc)r�r!s  r�r�zprocess_namespace.__init__�s
����
�
�
r�c#��K�t|��}tj|��|D]L\}}}|r|���t	|j|��}t
j|g|�Ri|��}||fV��MdS�z_Given a list of tuples yields a set of (fun, fun_name) tuples
        in random order.
        N)rr8�shuffle�clear_cacher�rWr�r)r��lsr[�fun_namer�r�r�s       r��iterzprocess_namespace.iter�s������"�X�X����r����$&�	"�	"� �H�d�D��
#�� � �"�"�"��$�*�h�/�/�C��#�C�7�$�7�7�7�$�7�7�C���/�!�!�!�!�	"�	"r�c�R�|j�|jjd���dS)z&Clear the cache of a Process instance.T)�_ignore_nspN)rW�_initr�r�s r�r[zprocess_namespace.clear_cache�s'���
������T��:�:�:�:�:r�c��|D]<\}}}d|z}t||��s!|jj�d|�d�}t|����=dS)z}Given a TestCase instance and a list of tuples checks that
        the class defines the required test method names.
        �test_z class should define a 'z' methodN)rUr�r��AttributeError)�cls�
test_classr\r]r�	meth_namer�s       r��test_class_coveragez%process_namespace.test_class_coverage�sn��
!�	*�	*�N�H�a���(�*�I��:�y�1�1�
*��(�1�1�1�9�9�9�>��$�S�)�)�)�
*�	*�	*r�c��td�|jD����}td�|jD����}td�ttj��D����}||z|z}|rt
d|z���dS)Nc��g|]
}|d��SrArlr�s  r�r�z*process_namespace.test.<locals>.<listcomp>
s��*�*�*�Q�A�a�D�*�*�*r�c��g|]
}|d��SrArlr�s  r�r�z*process_namespace.test.<locals>.<listcomp>s��1�1�1��q��t�1�1�1r�c�*�g|]}|ddk�|��S)rrrlr�s  r�r�z*process_namespace.test.<locals>.<listcomp>s!��C�C�C�1�q��t�s�{�{�Q�{�{�{r�z!uncovered Process class names: %r)r�rE�ignoredr�r�r�r�)re�thisrm�klass�leftouts     r��testzprocess_namespace.tests����*�*�#�'�*�*�*�+�+���1�1�S�[�1�1�1�2�2���C�C��F�N� 3� 3�C�C�C�D�D���'�>�U�*���	L��@�7�J�K�K�K�	L�	Lr�N)T)$r�r�r�r��utilsrm�gettersrr1r2r5r��
RLIMIT_NOFILEr.r4r0r
r3�setters�NORMAL_PRIORITY_CLASSr	�IOPRIO_CLASS_NONE�
IOPRIO_NORMALr:r#�SIGTERM�killers�CTRL_C_EVENT�CTRL_BREAK_EVENTrEr�r^r[�classmethodrhrqrlr�r�rGrG�su��������
��B��	�2�r�"�
�E�
�B���	�R�+�t�,�-�	�r�2��	�2�r�"�	�B���	�2�r��	�B���	��B��	����
�G�
�B���	��V�U�O�,�	�b�"��	��B��	��B��	��B��	�R��$�	��B��	��R��	��R��	�R��$�	��B��	�r�2��	��R��	�2�r��	�B���	�R���#�G�&
�)��V�R��$�%�%���V�R��$�%�%���Z��R�(�)�)���Y��B�'�(�(���-��]�B��+�,�,���(��X�r�2�&�'�'���>��X�� 4�7��<�=�=���.��^�R��,�-�-���)��Y��B�'�(�(���)��Y��B�'�(�(���-��]�B��+�,�,���=��]�B��E�(:�;�<�<���G��D��V�U�B�'�(�(����V�f�:�=�r�B�C�C���J��X�� 4�l�C�R�H�I�I���B��	B���F�$<�a�#@�"�E�F�F�G�G���F�$8�#;�R�@�A�A�G��E��^�'8�'8�':�':�&;�%>��C�D�D��
���*�B�/�	�B���	�2�r��	�b�"��	��R���G��F��]�V�%8�$;�R�@�A�A���]�V�%<�$?��D�E�E��
�'�/�G�
#�g�
-�C����"�"�"�"�;�;�;��	*�	*��[�	*��L�L��[�L�L�Lr�rGc��eZdZdZddifddddifddddifddifd	dd
difd	dd
difddddifd
dddifdej��fifddddifddifddifddddifdej��fifddifddifddifddifgZereddd
difgz
Ze	r	eddifgz
Ze
r	eddifgz
Zer	eddifgz
Zer	eddifgz
Ze
red difgz
Zed!d"ifgz
Zd#difd$ej��gfifd%difd&difgZeZed'���ZejZd(S))rHz�A container that lists all the module-level, system-related APIs.
    Utilities such as cpu_percent() are excluded. Usage:

    >>> ns = system_namespace
    >>> for fun, name in ns.iter(ns.getters):
    ...    fun()
    r!rlr�logicalFT�	cpu_statsrF�percpu�disk_io_counters�perdisk�disk_partitionsrE�
disk_usage�net_connectionsrD�net_if_addrs�net_if_statsrs�pernicr8r�r-�usersr)rnroryrxrw�win_service_iter�win_service_get)�alg�process_iterrAr<�cpu_times_percentc#��K�t|��}tj|��|D]6\}}}tt|��}tj|g|�Ri|��}||fV��7dSrY)rr8rZr�r�r�r)r\r]r�r�r�s     r�r^zsystem_namespace.iterHs�����
�"�X�X����r����$&�	"�	"� �H�d�D��&�(�+�+�C��#�C�7�$�7�7�7�$�7�7�C���/�!�!�!�!�	"�	"r�N)r�r�r�r�r�r�r'rsr/�HAS_GETLOADAVGr9r8r6r
r�r�rmrE�staticmethodr^rGrhrlr�r�rHrHsD��������
�b�"��	�b�9�e�,�-�	�b�9�d�+�,�	�b�"��	�b�8�U�+�,�	�b�8�T�*�+�	�R�)�T�!2�3�	�B���
�.�	�	��	�����+�	�B����0�	��R� �	��R� �	�B��4� 0�1�	�	��	�����+�	��R��	��B��	�"�b��	�2�r�"�%�G�(�8��Z��h��%5�6�7�7���,��\�2�r�*�+�+���6��+�R��4�5�5���.��^�R��,�-�-���1��&��B�/�0�0���8��'��R�0�1�1���&�	�2�6�7�7��
��R� �	����)�)�*�-�r�2�	��B��	�b�"�%�	�G��C��	"�	"��\�	"�,�?���r�rHc�P�tj|��s
J|���d|_|S)zA decorator to mark a TestCase class. When running parallel tests,
    class' unit tests will be run serially (1 process).
    T)�inspect�isclass�
_serialrun)ros r��	serialrunr�Ws/��
�?�5�!�!�(�(�5�(�(�!��E���Lr�c�8�d�}ttd||���S)zZDecorator which runs a test function and retries N times before
    actually failing.
    c�B�td|ztj���dS)Nz%r, retryingr)r�r�r~)ris r�rbz retry_on_failure.<locals>.logfunes"��
�n�s�"���4�4�4�4�4�4r�N)r_rr`rb)r]r�)r`rbs  r�rDrDas3��5�5�5��>�4��� � � � r�c����fd�}|S)z,Decorator to Ignore AccessDenied exceptions.c�J���tj�����fd���}|S)Nc�n��	�|i|��S#tj$r���s�tjd���wxYw)Nzraises AccessDenied)r��AccessDeniedr��SkipTest)r�r�r��only_ifs  ��r�r�z9skip_on_access_denied.<locals>.decorator.<locals>.wrapperos^���
?��s�D�+�F�+�+�+���&�
?�
?�
?��&�"����'�(=�>�>�>�	
?���s��)4r��r�r�r�s` �r�rjz(skip_on_access_denied.<locals>.decoratorns>����	���	�	�	?�	?�	?�	?�	?�
�	�	?��r�rl�r�rjs` r�rBrBls$���
�
�
�
�
��r�c����fd�}|S)z3Decorator to Ignore NotImplementedError exceptions.c�J���tj�����fd���}|S)Nc�x��	�|i|��S#t$r$���s�d�jz}tj|���wxYw)Nz4%r was skipped because it raised NotImplementedError)rHr�r�r�)r�r�r�r�r�s   ��r�r�z;skip_on_not_implemented.<locals>.decorator.<locals>.wrappersi���
-��s�D�+�F�+�+�+��&�
-�
-�
-��&�"���L���%���'��,�,�,�

-���s��.9r�r�s` �r�rjz*skip_on_not_implemented.<locals>.decorator~s>����	���	�	�		-�		-�		-�		-�		-�
�	�		-��r�rlr�s` r�rCrC|s$���������r��	127.0.0.1c���tjtj����5}|�|df��|���dcddd��S#1swxYwYdS)z6Return an unused TCP port. Subject to race conditions.rrGN)�
contextlib�closing�socket�bind�getsockname)�hostrs  r�rXrX�s���	�	�F�M�O�O�	,�	,�%���	�	�4��)�������!�!�!�$�%�%�%�%�%�%�%�%�%�%�%�%����%�%�%�%�%�%s�1A$�$A(�+A(c��|�|ttfvrd}tj||��}	tjdvr+|�tjtjd��|�|��|tj	kr|�
d��|S#t$r|����wxYw)zBinds a generic socket.N�rEr)�nt�cygwinrGrg)
rrr�r�r��
setsockopt�
SOL_SOCKET�SO_REUSEADDRr�r�listenr�r�)�family�type�addrrs    r�rYrY�s����|��7�H�"5�5�5����=���&�&�D�	�
�7�*�*�*��O�O�F�-�v�/B�A�F�F�F��	�	�$�����6�%�%�%��K�K��N�N�N���������
�
����
����s�A4B �  Cc�p�tjsJ�tj�|��r
J|���tjt
j|��}	|�|��|t
jkr|�	d��n##t$r|����wxYw|S)zBind a UNIX socket.rg)r�rr�r�r�r�r�r�rr�r�r�)r�r�rs   r�rZrZ�s����<���<��w�~�~�d�#�#�)�)�T�)�)�#��=����.�.�D���	�	�$�����6�%�%�%��K�K��N�N�N��������
�
����
������Ks�:B� B3r�c�F�tjtj|t����5}|�|��|�d��|���}tj|t��}	|�|��|���}	|���\}}||kr||fcddd��S|�	���B#t$r|�	���wxYw#1swxYwYdS)z^Build a pair of TCP sockets connected to each other.
    Return a (server, client) tuple.
    rgTN)r�r�r�rr�r�r��connectr�r�r+)r�r��llrM�caddr�as      r�r[r[�sH��
�	�F�M�&�+�>�>�	?�	?��2�
����
�
�
�
�	�	�!�����~�~�����M�&�+�.�.��	�
�I�I�d�O�O�O��M�M�O�O�E�
��)�)�+�+���4��5�=�=��q�6������������	�	�	�
���	�	�	�
�G�G�I�I�I��	����������������s+�AD�A
C3�C3�3 D�D�D�Dc��tjsJ�dx}}	t|tj���}|�d��tjtjtj��}|�d��|�|��n;#t$r.|�|�	��|�|�	���wxYw||fS)z�Build a pair of UNIX sockets connected to each other through
    the same UNIX file name.
    Return a (server, client) tuple.
    N�r�r)
r�rrZr�r�setblockingr�r�r�r�)r��server�clients   r�r\r\�s���
�<���<���F�V��!�$�V�-?�@�@�@�����1������v�~�v�/A�B�B�����1�������t�������������L�L�N�N�N����L�L�N�N�N�
�����
�F��s�BB�8Cc#�K�g}dx}}	|�ttjtj����|�ttjtj����t
��rn|�ttjtj����|�ttjtj����trmtrft��}t��}t|��\}}t|tj���}|||fD]}|�|���|V�|D]}|�
���||fD]}|�t|���dS#|D]}|�
���||fD]}|�t|���wxYw)z1Open as many socket families / types as possible.Nr�)r�rYr�rr�
SOCK_DGRAMrrr�HAS_CONNECTIONS_UNIXrQr\rZr�rM)�socks�fname1�fname2�s1�s2�s3r�rrs        r�r]r]�s�����
�E���F�V�#�
���[����1C�D�D�E�E�E�
���[����1B�C�C�D�D�D��?�?�	J��L�L��V�_�f�6H�I�I�J�J�J��L�L��V�_�f�6G�H�H�I�I�I��	 �)�	 ��\�\�F��\�\�F�$�V�,�,�F�B��!�&�v�/@�A�A�A�B��"�b�\�
 �
 �����Q����������	�	�A�
�G�G�I�I�I�I��f�%�	#�	#�E�� ��E�"�"�"��	#�	#���	�	�A�
�G�G�I�I�I�I��f�%�	#�	#�E�� ��E�"�"�"��	#���s�E"F�3Gc���ddl}tr2tr+ts$t	|tj��s
J|���|tjkr�d�|�d��D��}t|��dks
J|���|D]}d|cxkrdksnJ|����tst|��}|�|��dS|tjkrLt	|t��s
J|���tst|��}|�|��dS|tjkr!t#jd|���
J|���dSt'd|���)	z[Check a net address validity. Supported families are IPv4,
    IPv6 and MAC addresses.
    rNc�,�g|]}t|����Srl)r�r�s  r�r�z%check_net_address.<locals>.<listcomp>s��0�0�0�1��A���0�0�0r�rFr�z([a-fA-F0-9]{2}[:|\-]?){6}zunknown family %r)�	ipaddress�enumrr#r�IntEnumr�rrKrLr�IPv4Addressrr�IPv6Addressr��AF_LINKrV�matchr�)r�r�r��octs�nums     r�rWrWs��������8��8�D�8��&�$�,�/�/�7�7��7�7�/�
�����0�0��
�
�3���0�0�0���4�y�y�A�~�~�~�t�~�~�~��	)�	)�C���?�?�?�?�s�?�?�?�?�?�D�?�?�?�?��	!��4�=�=�D����d�#�#�#�#�#�	�6�?�	"�	"��$��$�$�*�*�d�*�*�$��	!��4�=�=�D����d�#�#�#�#�#�	�6�>�	!�	!��x�5�t�<�<�H�H�$�H�H�H�H�H��,�f�5�5�5r�c��d�}d�}d�}d�}d�}||��||��||��||��||��dS)z*Check validity of a connection namedtuple.c�D�t|��dk}t|��dvsJt|�����|d|jksJ|j���|d|jksJ|j���|d|jksJ|j���|d|jksJ|j���|d|jksJ|j���|d|jksJ|j���|r |d	|jksJ|j���dSdS)
N�)r*r�rrGr�rrrgr*)rLr�r�r��laddr�raddrr�r�)r�has_pids  r��check_ntuplez-check_connection_ntuple.<locals>.check_ntuple s5���d�)�)�q�.���4�y�y�F�"�"�"�C��I�I�"�"�"��A�w�$�'�!�!�!�4�7�!�!�!��A�w�$�+�%�%�%�t�{�%�%�%��A�w�$�)�#�#�#�T�Y�#�#�#��A�w�$�*�$�$�$�d�j�$�$�$��A�w�$�*�$�$�$�d�j�$�$�$��A�w�$�+�%�%�%�t�{�%�%�%��	1���7�d�h�&�&�&���&�&�&�	1�	1�&�&r�c���|jtttfvsJ|j���t�*t|jtj��s
J|���n$t|jt��s
J|���|jtkr�tj|j|j	��}tj|��5	|�|j
ddf��n2#tj$r }|jtjkr�Yd}~nd}~wwxYwddd��dS#1swxYwYdS|jtkr$|jt$jksJ|j���dSdS)Nr)r�rrr�r�rr�r�r�r�r�r�r�r��errorr-�
EADDRNOTAVAILr�r��	CONN_NONE)rr�r/s   r��check_familyz-check_connection_ntuple.<locals>.check_family,s����{�w��'�:�:�:�:�D�K�:�:�:����d�k�4�<�8�8�>�>�$�>�>�8�>��d�k�3�/�/�5�5��5�5�/��;�'�!�!�
�
�d�k�4�9�5�5�A��#�A�&�&�
�
���F�F�D�J�q�M�1�-�.�.�.�.���|�����y�E�$7�7�7��8�7�7�7�7���������
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
��[�G�
#�
#��;�&�"2�2�2�2�D�K�2�2�2�$�
#�2�2s<�D'�"C(�'D'�(D�7D�
D'�D�D'�'D+�.D+c���ttdt����}|jtjtj|fvsJ|j���t�*t|jtj��s
J|���n$t|jt��s
J|���|jtjkr$|j
tjksJ|j
���dSdS)N�SOCK_SEQPACKET)
r�r��objectr�rr�r�rr�r�r�r�r�)rr�s  r��
check_typez+check_connection_ntuple.<locals>.check_typeAs��� ��)9�6�8�8�D�D���y�V�/��1B�+�-�-�-�-�.2�i�-�-�-����d�i���6�6�<�<��<�<�6�<��d�i��-�-�3�3�t�3�3�-��9��)�)�)��;�&�"2�2�2�2�D�K�2�2�2�*�)�2�2r�c��|j|jfD]�}|jttfvr�t|t��sJt|�����|s�Ft|jt��sJt|j�����d|jcxkrdksnJ|j���t|j|j����|jtkr,t|t��sJt|�������dS)Nri��)r�r�r�rrrr(r��portr�rW�ipr�r)rr�s  r��check_addrsz,check_connection_ntuple.<locals>.check_addrsMs���Z���,�		9�		9�D��{�w��1�1�1�!�$��.�.�:�:��T�
�
�:�:�.����!�$�)�S�1�1�B�B�4��	�?�?�B�B�1��D�I�.�.�.�.��.�.�.�.�.��	�.�.�.�!�$�'�4�;�7�7�7�7����'�'�!�$��,�,�8�8�d�4�j�j�8�8�,��		9�		9r�c��t|jt��sJ|j���d�tt��D��}|j|vsJ|j���|jttfvr6|jtkr&|jtj
ksJ|j���dS|jtj
ksJ|j���dS)Nc�b�g|],}|�d���tt|����-S)�CONN_r�r�s  r�r�zAcheck_connection_ntuple.<locals>.check_status.<locals>.<listcomp>\sB��,�,�,���\�\�'�*�*�,�'�&�!�$�$�,�,�,r�)rr�rr�r�r�rrr�rr�)r�validss  r��check_statusz-check_connection_ntuple.<locals>.check_statusZs����$�+�s�+�+�8�8�T�[�8�8�+�,�,�c�&�k�k�,�,�,���{�f�$�$�$�d�k�$�$�$��;�7�H�-�-�-�$�)�{�2J�2J��;�&�"2�2�2�2�D�K�2�2�2�2�2��;�&�"2�2�2�2�D�K�2�2�2�2�2r�Nrl)rr�r�r�r�r�s      r��check_connection_ntupler�s���
1�
1�
1�@�@�@�*
@�
@�
@�9�9�9�@�@�@��L������L������J�t�����K������L������r�c��	ddl}t|d��st�	|�|��S#t$rddl}|�|��cYSwxYw)z,Backport of importlib.reload of Python 3.3+.rN�reload)�	importlibrUrr��imp)�moduler�r�s   r�r^r^ps���(������y�(�+�+�	���	�����'�'�'��	�"�"�"��
�
�
��z�z�&�!�!�!�!�!�"���s�3�#A�Ac��tj�tj�|����d}tjddkrddl}|�||��Stjdd�dkr$ddlm	}|||���
��Sddl}|j�
||��}|j�|��}|j�|��|S)Nrr�r)�SourceFileLoader)r�r��splitextr�r�r�r��load_source�importlib.machineryr��load_module�importlib.util�util�spec_from_file_location�module_from_spec�loader�exec_module)r�r�r�r�r��spec�mods       r�r_r_}s���
�7���B�G�,�,�T�2�2�3�3�A�6�D�
����a����
�
�
����t�T�*�*�*�	�	�"�1�"�	��	'�	'�8�8�8�8�8�8����d�+�+�7�7�9�9�9������~�5�5�d�D�A�A���n�-�-�d�3�3�������$�$�$��
r�c�:�tj|t��dS)zRaise a warning msg.N)�warningsr`�UserWarning)r�s r�r`r`�s���M�#�{�#�#�#�#�#r�c��t|��}|j}t|��dks|dtkrdSt	|dd��}t|t��sdSt
d�|D����S)z-Check if object is an instance of namedtuple.rGrF�_fieldsNc3�FK�|]}t|��tkV��dSr�)r�r)r��ns  r��	<genexpr>z is_namedtuple.<locals>.<genexpr>�s,����)�)�!�t�A�w�w�#�~�)�)�)�)�)�)r�)r��	__bases__rLr(r�rrE)r��t�brs    r�rbrb�sy���Q���A�	��A�
�1�v�v��{�{�a��d�e�m�m��u���9�d�#�#�A��a������u��)�)�q�)�)�)�)�)�)r�c#�|��K�trdnd�d�t|�z���}��fd�tj�����D��}tj|��}tj||��	tj
|��|V�t|��dS#t|��wxYw)z�Ctx manager which picks up a random shared CO lib used
        by this process, copies it in another location and loads it
        in memory via ctypes. Return the new absolutized path.
        r�r�z.sor�c���g|]R}tj�|j��d�kr"�|j���v�K|j��SS)rG)r�r�r��lower)r�r�r��exts  ��r�r�z'copyload_shared_lib.<locals>.<listcomp>�s[���'�'�'�1��� � ���(�(��+�s�2�2��q�v�|�|�~�~�%�%���%�%�%r�N)r#rQr�r�rrr8r9r�r��ctypes�CDLLrM)r��dst�libsrr�rs    @@r�rara�s��������*�f�f�(��������-�-�-��'�'�'�'�'��� 0� 0� <� <� >� >�'�'�'���m�D�!�!�����S�!�!�!�	��K������I�I�I���������K��������s�B*�*B;c#��	K�ddlm}ddlm}d�	t|�	z���}�	fd�t	j�����D��}tr1|s/d�t	j�����D��}tj	|��}tj||��d}	tj|��}|V�|�Ctj
jj}|jg|_||j��}|dkr
|��t'|��dS#|�Ctj
jj}|jg|_||j��}|dkr
|��t'|��wxYw)	z�Ctx manager which picks up a random shared DLL lib used
        by this process, copies it in another location and loads it
        in memory via ctypes.
        Return the new absolutized, normcased path.
        r)�wintypes)�WinErrorz.dllr�c���g|]�}|j�������rZdtj�|j�����vr"d|j���v��|j���S)r��wow64)r�rrr�r�)r�r�rs  �r�r�z'copyload_shared_lib.<locals>.<listcomp>�s����/�/�/�1�������'�'��,�,�/��B�G�,�,�Q�V�4�4�:�:�<�<�<�<��q�v�|�|�~�~�-�-���.�-�-r�c��g|]A}dtj�|j�����v�:|j��BS)r�)r�r�r�rr�s  r�r�z'copyload_shared_lib.<locals>.<listcomp>�sO��@�@�@�q��b�g�.�.�q�v�6�6�<�<�>�>�>�>��F�>�>�>r�N)rrrrQr�r�rrr#r8r9r�r��WinDLL�windll�kernel32�FreeLibrary�HMODULE�argtypes�_handlerM)
r�rrrrr�cfiler!rwrs
         @r�rara�s������	$�#�#�#�#�#�#�#�#�#�#�#�������-�-�-��/�/�/�/��� 0� 0� <� <� >� >�/�/�/���	@��	@�@�@�F�N�$4�$4�$@�$@�$B�$B�@�@�@�D��m�D�!�!�����S�!�!�!���	��M�#�&�&�E��I�I�I�� �$�m�4�@��(0�(8�'9��$�!�k�%�-�0�0���!�8�8��H�J�J�J���������
� �$�m�4�@��(0�(8�'9��$�!�k�%�-�0�0���!�8�8��H�J�J�J���������s
�:D(�(AE>c�&�td���dS)NTr=)r=rlr�r��cleanup_test_procsr'�s���D�!�!�!�!�!�!r�c�*�tj|��Sr�)r��exit)r'�frames  r�r�r��s��S�X�c�]�]�r�r�)F)TFr�)r�)r�)rE)�r��
__future__r�atexitr�rr-r�r�r�r�r8rVr�r�r#r�r|rr�r�r�r�r�rrrrr�rrr	r
rrr
�psutil._commonrrr�psutil._compatrrrrrrrrr��	unittest2rr�catch_warnings�simplefilterr�r��__all__�builtin_module_namesr#rprrdr*�maxsizer-r"r!r,r r�r'r'r(�decoder)rr�ASCII_FSr�r�r�r��__file__r%r&�HEREr�rUr�r.r/r�r0r2r3�HAS_NET_IO_COUNTERSr4r1r5r6r�rwr7r�r8r9�HAS_THREADS�getuid�SKIP_SYSCONSr�r$r	�devnullr�registerr�r�r+r�r�r�r�r�r�r�r�r�r>r@r?r;rryr<r=rSrRr]r rUr�rVrTrMr��contextmanagerrLrNrQr�rF�skipIfrErIr:rGrHr�rDrBrCrXrYrZr[r\r]rWr�r^r_r`rbrar'rlr�r��<module>rAs�����&�%�%�%�%�%�
�
�
�
�����
�
�
�
���������	�	�	�	�����	�	�	�	�
�
�
�
�	�	�	�	�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
���������
�
�
�
���������������������������������������
�
�
�
�������������������������������������������&�&�&�&�&�&�&�&�&�&�&�&�(�(�(�(�(�(�*�*�*�*�*�*�,�,�,�,�,�,������� � � � � � � � � � � � �������"�"�"�"�"�"� � � � � � ��!��O�O�O�O� � � � ��������������	 ��	 �	"�	"������h�'�'�'�����������������������������
��v����K�K�K�K��D�$�$�$��Z�S�-�-�����#��!�R�Z�/�O�>�R�Z�3O��
�
'��
��;�� ���
�#��'����
���!�O�J��a��N������A���
�7�f���!�I�B�I�K�K�/�M�M�!�I�B�I�K�K�/�M���9�����)�)�0�0��9J�K�K���(��$�3�$�&�&�,�,�.�.�2G�G���7����G�L�L������*�*�D�$�7�7�9�9���g�l�l�8�Y�/�/��	�w��������1�1�2�2���*�U����7�6�>�>�:�:���w�v�z�*�*������.�.���g�f�n�i�0�0��
�W�V�^�X�
.�
.�
��'�&�.�-�8�8���g�f�&7�8�8���7�6�>�9�5�5���w�v�~�}�=�=��
�W�V�^�X�
.�
.�
��g�f�&7�8�8���%�H�$�$�/E�v�/E�/G�/G�*H�*H�K�K�������K�K�K������7�6�>�2�2��"�7�6�+A�B�B���g�f�n�i�0�0�����2�)�"�)�+�+��"2��
���@�[�]�]�
�
�$�r�z�4�
 �
 ������
����3�3�3�3�v�;�;�3�3�3��
�'�&�)�V�V�X�X�
.�
.�����������
�(�(�(�(�(��!�(�(�(�`����$�$�$���$�N�#�#���#�L*�*�*�Z������&������6 &�~�N�U/�U/�U/�U/�p-�-�-�-�J!�!�!�0���(7�7�7�7�7�F�7�7�7�t���%�d�N������������#�^�4�T���/�/�/����/�/������n����������
�
�
�B
�
�
��������9�9�9�9�<	*�	*�	*�	*�"�����x� ����.���.2�.2�.2�.2�.2�X�.2�.2�.2�b����+�,�,�O%�O%�O%�O%�O%�^�O%�O%�-�,�O%�dX�X�X�v
�
�
�FL�FL�FL�FL�FL�FL�FL�FL�R?@�?@�?@�?@�?@�?@�?@�?@�D���(� � � � �
�
�
�
� ����0%�%�%�%��[�t�����"!'� 2���������.���.��#�#���#�46�6�6�4J�J�J�d
(�
(�
(�
�
�
�*$�$�$�
	*�	*�	*�	�9����������&��#�#�#���#�X��"�"���"�	�D��F�M�&�.�"B�"B�C�C�C�C�C�D�DsH�/C6�6D9�
D+�D9�+D/	�/D9�2D/	�3D9�8D9�"M=�=N�N

Filemanager

Name Type Size Permission Actions
__init__.cpython-311.pyc File 88.05 KB 0644
__main__.cpython-311.pyc File 395 B 0644
runner.cpython-311.pyc File 19.78 KB 0644
test_aix.cpython-311.pyc File 6.38 KB 0644
test_bsd.cpython-311.pyc File 39.97 KB 0644
test_connections.cpython-311.pyc File 34.39 KB 0644
test_contracts.cpython-311.pyc File 52.41 KB 0644
test_linux.cpython-311.pyc File 154.4 KB 0644
test_memleaks.cpython-311.pyc File 37.53 KB 0644
test_misc.cpython-311.pyc File 51.58 KB 0644
test_osx.cpython-311.pyc File 13.74 KB 0644
test_posix.cpython-311.pyc File 25.72 KB 0644
test_process.cpython-311.pyc File 111.08 KB 0644
test_sunos.cpython-311.pyc File 2.78 KB 0644
test_system.cpython-311.pyc File 62.06 KB 0644
test_testutils.cpython-311.pyc File 34.2 KB 0644
test_unicode.cpython-311.pyc File 19.95 KB 0644
test_windows.cpython-311.pyc File 59.02 KB 0644