[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.135.185.78: ~ $
U

�=�_';�@s�dZddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
dd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZe
�rBddlZddlZddlmZd*dd�Z dd�Z!dd�Z"dd�Z#dd �Z$e�%e
d!�Gd"d#�d#e��Z&e�%e
d!�Gd$d%�d%e��Z'e�%e
d!�Gd&d'�d'e��Z(e)d(k�r�dd)l*m+Z+e+e,�dS)+zPOSIX specific tests.�N)�AIX)�BSD)�LINUX)�MACOS)�OPENBSD)�POSIX)�SUNOS)�
CI_TESTING)�spawn_testproc)�HAS_NET_IO_COUNTERS)�mock)�PsutilTestCase)�
PYTHON_EXE)�retry_on_failure)�sh)�skip_on_access_denied)�	terminate)�unittest)�which)�getpagesizec	Cs�dg}tr|�d�|dk	r0|�dt|�g�nts8trD|�d�n
|�d�trftd�}|�||�}|�d|g�t|�}tr�|�	�}n|�	�d	d�}g}|D]8}|�
�}zt|�}Wntk
r�YnX|�|�q�|dkr�|S|d
SdS)z|
    Wrapper for calling the ps command with a little bit of cross-platform
    support for a narrow range of features.
    �psz--no-headersNz-pz-AZax)�command�comm�startZstimez-o�r)
r�append�extend�strrr�set�getr�
splitlines�strip�int�
ValueError)Zfmt�pid�cmdZfmt_map�outputZ
all_output�line�r(�J/opt/alt/python38/lib64/python3.8/site-packages/psutil/tests/test_posix.pyr-s6


rcCsd}trd}t||���dS)Nrrr)rr�split�r$Zfieldr(r(r)�ps_nameisr,cCsd}tstrd}t||�S)Nr�args)rrrr+r(r(r)�ps_argspsr.cCsd}trd}t||�S)NZrssZrssize�rrr+r(r(r)�ps_rsswsr0cCsd}trd}t||�S)NZvszZvsizer/r+r(r(r)�ps_vsz~sr1z
POSIX onlyc@s�eZdZdZedd��Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Ze�e
�dd���Ze�e
�dd���Zdd�Zdd�Zdd�Zdd�Ze�ep�ed�dd��Zdd �Zd!d"�Ze�ed#�e�ed$�d%d&���Zd'S)(�TestProcesszBCompare psutil results against 'ps' command line utility (mainly).cCsttddgtjd�j|_dS)Nz-Ez-O)�stdin)r
r�
subprocess�PIPEr$��clsr(r(r)�
setUpClass�s
�zTestProcess.setUpClasscCst|j�dS�N)rr$r6r(r(r)�
tearDownClass�szTestProcess.tearDownClasscCs,td|j�}t�|j���}|�||�dS)N�ppid)rr$�psutil�Processr;�assertEqual)�selfZppid_psZppid_psutilr(r(r)�	test_ppid�szTestProcess.test_ppidcCs.td|j�}t�|j���j}|�||�dS)NZuid)rr$r<r=�uids�realr>)r?Zuid_psZ
uid_psutilr(r(r)�test_uid�szTestProcess.test_uidcCs.td|j�}t�|j���j}|�||�dS)NZrgid)rr$r<r=ZgidsrBr>)r?Zgid_psZ
gid_psutilr(r(r)�test_gid�szTestProcess.test_gidcCs,td|j�}t�|j���}|�||�dS)N�user)rr$r<r=�usernamer>)r?Zusername_psZusername_psutilr(r(r)�
test_username�szTestProcess.test_usernamec	CsJt��}tjdtd��*}|�|��t|��j	��|j
s<t�W5QRXdS)Nzpsutil.pwd.getpwuid�Zside_effect)r<r=r�patch�KeyErrorr>rFrrArB�called�AssertionError)r?�pZfunr(r(r)�test_username_no_resolution�sz'TestProcess.test_username_no_resolutioncCs<t�d�t|j�}t�|j���dd}|�||�dS)N皙�����?r�)�time�sleepr0r$r<r=�memory_infor>)r?Zrss_psZ
rss_psutilr(r(r)�test_rss_memory�s

zTestProcess.test_rss_memorycCs<t�d�t|j�}t�|j���dd}|�||�dS)NrOrrP)rQrRr1r$r<r=rSr>)r?Zvsz_psZ
vsz_psutilr(r(r)�test_vsz_memory�s

zTestProcess.test_vsz_memorycCsvt|j�}tj�|���}t�|j�����}t	�
dd|�}t	�
dd|�}t	�
dd|�}t	�
dd|�}|�||�dS)Nz\d.\d�z\d)r,r$�os�path�basename�lowerr<r=�name�re�subr>)r?Zname_psZname_psutilr(r(r)�	test_name�s
zTestProcess.test_namec
Cs^d}dddg}tjd|d��8tjd|d��t��}|�|��d�W5QRXW5QRXdS)N�long-program-namezlong-program-name-extendedZfooZbar�psutil._psplatform.Process.name�Zreturn_value�"psutil._psplatform.Process.cmdline)rrIr<r=r>r[)r?r[�cmdlinerMr(r(r)�test_name_long�s
��zTestProcess.test_name_longc
Cs\d}tjd|d��@tjdt�dd�d��t��}|�|��d�W5QRXW5QRXdS�Nr_r`rarbrrVrH)rrIr<ZAccessDeniedr=r>r[�r?r[rMr(r(r)�test_name_long_cmdline_ad_exc�s�
�z)TestProcess.test_name_long_cmdline_ad_excc
Cs\d}tjd|d��@tjdt�dd�d��t��}|�tj|j�W5QRXW5QRXdSre)rrIr<Z
NoSuchProcessr=�assertRaisesr[rfr(r(r)�test_name_long_cmdline_nsp_exc�s�
�z*TestProcess.test_name_long_cmdline_nsp_exczps -o start not availablecCs\td|j�}t�|j���}tj�|��d�}t|�}tj�|��d�}|�	|||g�dS)Nrz%H:%M:%S)
rr$r<r=Zcreate_time�datetimeZ
fromtimestamp�strftime�round�assertIn)r?Ztime_psZtime_psutilZtime_psutil_tstampZround_time_psutilZround_time_psutil_tstampr(r(r)�test_create_time�s����zTestProcess.test_create_timecCs`t|j�}t�|j���}z|�||�Wn0tk
rZ|dt|��}|�||�YnXdSr9)r,r$r<r=Zexer>rL�len)r?Zps_pathnameZpsutil_pathnameZadjusted_ps_pathnamer(r(r)�test_exes
zTestProcess.test_execCs0t|j�}d�t�|j����}|�||�dS)N� )r.r$�joinr<r=rcr>)r?Z
ps_cmdlineZpsutil_cmdliner(r(r)�test_cmdlines
zTestProcess.test_cmdlineznot reliable on SUNOSznot reliable on AIXcCs(td|j�}t����}|�||�dS)N�nice)rr$r<r=rtr>)r?Zps_niceZpsutil_nicer(r(r)�	test_niceszTestProcess.test_niceN)�__name__�
__module__�__qualname__�__doc__�classmethodr8r:r@rCrDrGrNrrrTrUr^rdrgrir�skipIfrrrnrprsrrrur(r(r(r)r2�s6

	




r2c@s�eZdZdZe�dd��Ze�ed�e�e	d�d�e�e
d�dd	����Ze�eo^e
��d
�e�dd���Zd
d�Zdd�Zdd�Zdd�Ze�ed�e�dd���ZdS)�TestSystemAPIszTest some system APIs.cs~ttd���t���ts$tr0d�kr0��dd�t��t��dkrz�fdd��D��fdd��D�}|�dt	|��dS)Nr$rrcsg|]}|�kr|�qSr(r(��.0�x)�pids_psr(r)�
<listcomp>4sz,TestSystemAPIs.test_pids.<locals>.<listcomp>csg|]}|�kr|�qSr(r(r})�pids_psutilr(r)r�5szdifference: )
�sortedrr<Zpidsrr�insertro�failr)r?�
differencer()r�r�r)�	test_pids's�zTestSystemAPIs.test_pidszunreliable on SUNOSZifconfigzno ifconfig cmdz
not supportedcCsPtd�}tjdd���D]2}|��D]}|�|�r$qq$|�d||f�qdS)Nzifconfig -aT)Zpernicz/couldn't find %s nic in 'ifconfig -a' output
%s)rr<Znet_io_counters�keysr*�
startswithr�)r?r&Znicr'r(r(r)�test_nic_names:s
��zTestSystemAPIs.test_nic_nameszunreliable on CIcCs�td�}|��s|�d��|�d�}dd�|D�}dd�|D�}|�t|�tt����t��D] }|�|j	|�|�|j
|�q`dS)NZwhozno users on this system�
cSsg|]}|��d�qS)r�r*r}r(r(r)r�Osz-TestSystemAPIs.test_users.<locals>.<listcomp>cSsg|]}|��d�qS)rr�r}r(r(r)r�Ps)rr!ZskipTestr*r>ror<�usersrmr[Zterminal)r?�out�linesr�Z	terminals�ur(r(r)�
test_usersHs

zTestSystemAPIs.test_usersc	CsFtjdttjd�d��&}|�ttjjt	�
��|js8t�W5QRXdS)Nzpsutil._psposix.os.killrVrH)
rrI�OSError�errno�EBADFrhr<�_psposixZ
pid_existsrW�getpidrKrL�r?�mr(r(r)�test_pid_exists_let_raiseVs
�z(TestSystemAPIs.test_pid_exists_let_raisec	CsFtjdttjd�d��&}|�ttjjt	�
��|js8t�W5QRXdS)N�psutil._psposix.os.waitpidrVrH)
rrIr�r�r�rhr<r��wait_pidrWr�rKrLr�r(r(r)�test_os_waitpid_let_raise_s
�z(TestSystemAPIs.test_os_waitpid_let_raisec	CsNtjdttjd�d��.}|jtjjtjj	t
��dd�|js@t
�W5QRXdS)Nr�rVrHg{�G�z�?)Ztimeout)rrIr�r�ZEINTRrhr<r�ZTimeoutExpiredr�rWr�rKrLr�r(r(r)�test_os_waitpid_eintrgs
��z$TestSystemAPIs.test_os_waitpid_eintrc	Cs>tjddd��&}|�ttjjt���|j	s0t
�W5QRXdS)Nr�)r���ra)rrIrhr#r<r�r�rWr�rKrLr�r(r(r)�test_os_waitpid_bad_ret_statusps��z-TestSystemAPIs.test_os_waitpid_bad_ret_statuszunreliable on AIXc
Cs�dd�}d}tjdd�D]�}t�|j�}z||j�\}}}}WnRtk
r�}	z4t|	���}	d|	kstd|	kstd|	kr~WY�
qn�W5d}	~	XYqX|j|j	||d	�|j|j
||d	�|j|j||d	�|j|j|d
d	�qdS)NcSsvtd|���}|�d�d}|��}t|d�d}t|d�d}t|d�d}t|d�dd	��}||||fS)
Nzdf -k %sr�rrP����%rV)rr!r*r"�float�replace)�devicer�r'Zfields�total�used�free�percentr(r(r)�df|sz*TestSystemAPIs.test_disk_usage.<locals>.dfi@F)�allzno such file or directoryzraw devices not supportedzpermission denied)Zdeltar)
r<Zdisk_partitionsZ
disk_usageZ
mountpointr��RuntimeErrorrrZZassertAlmostEqualr�r�r�r�)
r?r�Z	tolerance�partZusager�r�r�r��errr(r(r)�test_disk_usageys&
��
zTestSystemAPIs.test_disk_usageN)rvrwrxryrr�rr{rrrr�r	r<r�r�r�r�r�r�rr�r(r(r(r)r|#s"

			
r|c@seZdZdd�ZdS)�TestMisccCs4t�}|�|d�|�|t���|�|tj�dS)Nr)rZ
assertGreaterr>�resource�mmapZPAGESIZE)r?Zpagesizer(r(r)�test_getpagesize�szTestMisc.test_getpagesizeN)rvrwrxr�r(r(r(r)r��sr��__main__)�
run_from_name)N)-ryrjr�rWr\r4rQr<rrrrrrrZpsutil.testsr	r
rrr
rrrrrrrr�r�Zpsutil._psutil_posixrrr,r.r0r1r{r2r|r�rvZpsutil.tests.runnerr��__file__r(r(r(r)�<module>sZ
<y	


Filemanager

Name Type Size Permission Actions
__init__.cpython-38.opt-1.pyc File 44.89 KB 0644
__init__.cpython-38.pyc File 46.44 KB 0644
__main__.cpython-38.opt-1.pyc File 285 B 0644
__main__.cpython-38.pyc File 285 B 0644
runner.cpython-38.opt-1.pyc File 10.84 KB 0644
runner.cpython-38.pyc File 10.84 KB 0644
test_aix.cpython-38.opt-1.pyc File 3.3 KB 0644
test_aix.cpython-38.pyc File 3.3 KB 0644
test_bsd.cpython-38.opt-1.pyc File 19.53 KB 0644
test_bsd.cpython-38.pyc File 19.53 KB 0644
test_connections.cpython-38.opt-1.pyc File 15.13 KB 0644
test_connections.cpython-38.pyc File 15.43 KB 0644
test_contracts.cpython-38.opt-1.pyc File 24.81 KB 0644
test_contracts.cpython-38.pyc File 25.64 KB 0644
test_linux.cpython-38.opt-1.pyc File 67.56 KB 0644
test_linux.cpython-38.pyc File 68.67 KB 0644
test_memleaks.cpython-38.opt-1.pyc File 22.59 KB 0644
test_memleaks.cpython-38.pyc File 22.59 KB 0644
test_misc.cpython-38.opt-1.pyc File 22.69 KB 0644
test_misc.cpython-38.pyc File 22.92 KB 0644
test_osx.cpython-38.opt-1.pyc File 7.1 KB 0644
test_osx.cpython-38.pyc File 7.1 KB 0644
test_posix.cpython-38.opt-1.pyc File 12.36 KB 0644
test_posix.cpython-38.pyc File 12.46 KB 0644
test_process.cpython-38.opt-1.pyc File 45.69 KB 0644
test_process.cpython-38.pyc File 46.52 KB 0644
test_sunos.cpython-38.opt-1.pyc File 1.5 KB 0644
test_sunos.cpython-38.pyc File 1.5 KB 0644
test_system.cpython-38.opt-1.pyc File 25.65 KB 0644
test_system.cpython-38.pyc File 26.92 KB 0644
test_testutils.cpython-38.opt-1.pyc File 15.6 KB 0644
test_testutils.cpython-38.pyc File 16.27 KB 0644
test_unicode.cpython-38.opt-1.pyc File 10.87 KB 0644
test_unicode.cpython-38.pyc File 10.87 KB 0644
test_windows.cpython-38.opt-1.pyc File 27.81 KB 0644
test_windows.cpython-38.pyc File 28 KB 0644