HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/osm/venv/lib/python3.10/site-packages/psutil/tests/__pycache__/test_scripts.cpython-310.pyc
o

=i5�@s�dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddl
mZddl
m
Z
ddl
mZdd	l
mZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddl
mZddl
mZddl
mZddl
mZej�ed�Zej�ed�Zejjeo�ej�e�dd�Gdd�de��Zejjeo�ej�e�dd�Gdd�de��Z ejjeo�ej�e�dd�Gdd�de��Z!dS)zTest various scripts.�N)�POSIX)�WINDOWS)�
CI_TESTING)�HAS_BATTERY)�HAS_MEMORY_MAPS)�HAS_SENSORS_BATTERY)�HAS_SENSORS_FANS)�HAS_SENSORS_TEMPERATURES)�
PYTHON_EXE)�PYTHON_EXE_ENV)�ROOT_DIR)�SCRIPTS_DIR)�PsutilTestCase)�import_module_by_path)�psutil)�shZinternalzsetup.pyzcan't find scripts/ directory��reasonc@s�eZdZedd��Zedd��Zdd�Zejj	e
dd�d	d
��Zdd�Zd
d�Z
dd�Zdd�Zejj	eo:e��dd�dd��Zdd�Zdd�Zdd�Zdd�Zejj	edd�dd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zejj	e d-d�d.d/��Z!d0d1�Z"ejj	e#dd�d2d3��Z$ejj	e%dd�d4d5��Z&ejj	e'dd�ejj	e(d6d�d7d8���Z)ejj	e'dd�ejj	e(d6d�d9d:���Z*d;S)<�TestExampleScriptsc
Os�|�dt�tj�t|�}t|g}|D]}|�|�qzt|fi|���	�}Wnt
yD}zdt|�vr?t|�WYd}~S�d}~ww|sKJ|��|S)N�envZAccessDenied)�
setdefaultr�os�path�joinr
r
�appendr�strip�RuntimeError�str)�exe�args�kwargs�cmd�arg�out�err�r%�G/opt/osm/venv/lib/python3.10/site-packages/psutil/tests/test_scripts.py�
assert_stdout0s��z TestExampleScripts.assert_stdoutcCsPtj�t|�}t|dd��}|��}Wd�n1swYt�|�dS�N�utf8)�encoding)rrrr
�open�read�ast�parse)r�f�srcr%r%r&�
assert_syntaxAs

�z TestExampleScripts.assert_syntaxcCs^t|�}t�t�D]#}|�d�r,dtj�|�d|vr,t�dtj�	t|��d��Sq	dS)N�.pyZtest_rzno test defined for z script)
�dirr�listdirr
�endswithr�splitext�pytest�failr)�selfZmeths�namer%r%r&�
test_coverageHs
����z TestExampleScripts.test_coveragez
POSIX onlyrcCsjt�t�D]-\}}}|D]%}|�d�r1tj�||�}tjt�|�tj@s1t	�
|�d��SqqdS)Nr2z is not executable)r�walkr
r5rr�stat�S_IXUSR�ST_MODEr7r8)r9�root�dirs�files�filerr%r%r&�test_executableTs
���z"TestExampleScripts.test_executablecC�|�d�dS)Nz
disk_usage.py�r'�r9r%r%r&�test_disk_usage]�z"TestExampleScripts.test_disk_usagecCrE)Nzfree.pyrFrGr%r%r&�	test_free`rIzTestExampleScripts.test_freecCrE)Nz
meminfo.pyrFrGr%r%r&�test_meminfocrIzTestExampleScripts.test_meminfocC�|�dtt����dS)Nzprocinfo.py�r'rr�getpidrGr%r%r&�
test_procinfofsz TestExampleScripts.test_procinfozno userscCrE)Nzwho.pyrFrGr%r%r&�test_whoi�zTestExampleScripts.test_whocCrE)Nzps.pyrFrGr%r%r&�test_psmrIzTestExampleScripts.test_pscCrE)Nz	pstree.pyrFrGr%r%r&�test_pstreeprIzTestExampleScripts.test_pstreecCrE)Nz
netstat.pyrFrGr%r%r&�test_netstatsrIzTestExampleScripts.test_netstatcCrE)Nzifconfig.pyrFrGr%r%r&�
test_ifconfigvrIz TestExampleScripts.test_ifconfig�
not supportedcCrL)Nzpmap.pyrMrGr%r%r&�	test_pmapyszTestExampleScripts.test_pmapcCs*dt����jvrt�d�S|�d�dS)NZussrVzprocsmem.py)r�ProcessZmemory_full_info�_fieldsr7�skipr'rGr%r%r&�
test_procsmem}s
z TestExampleScripts.test_procsmemcCrE)Nz
killall.py�r1rGr%r%r&�test_killall�rIzTestExampleScripts.test_killallcCrE)Nz	nettop.pyr\rGr%r%r&�test_nettop�rIzTestExampleScripts.test_nettopcCrE)Nztop.pyr\rGr%r%r&�test_top�rIzTestExampleScripts.test_topcCrE)Nziotop.pyr\rGr%r%r&�
test_iotop�rIzTestExampleScripts.test_iotopcCs,|�dt�����}tt���|vsJ�dS)Nzpidof.py)r'rrXr:rrrN)r9�outputr%r%r&�
test_pidof�szTestExampleScripts.test_pidofzWINDOWS onlycCrE)Nzwinservices.pyrFrGr%r%r&�test_winservices�rQz#TestExampleScripts.test_winservicescCrE)Nzcpu_distribution.pyr\rGr%r%r&�test_cpu_distribution�rIz(TestExampleScripts.test_cpu_distributioncC� t��s	t�d�S|�d�dS)Nzno temperaturesztemperatures.py)rZsensors_temperaturesr7rZr'rGr%r%r&�test_temperatures��
z$TestExampleScripts.test_temperaturescCre)Nzno fanszfans.py)rZsensors_fansr7rZr'rGr%r%r&�	test_fans�rgzTestExampleScripts.test_fansz
no batterycCrE)Nz
battery.pyrFrGr%r%r&�test_battery��zTestExampleScripts.test_batterycCrE)Nz
sensors.pyrFrGr%r%r&�test_sensors�rjzTestExampleScripts.test_sensorsN)+�__name__�
__module__�__qualname__�staticmethodr'r1r;r7�mark�skipifrrDrHrJrKrOrrZusersrPrRrSrTrUrrWr[r]r^r_r`rbrrcrdr	rfrrhrrrirkr%r%r%r&r+sN







rz&can't find scripts/internal/ directoryc@s8eZdZedd��Zdd�Zejje	dd�dd��Z
d	S)
�TestInternalScriptsccs0�t�t�D]}|�d�rtj�t|�VqdS)Nr2)rr4�INTERNAL_SCRIPTS_DIRr5rr)r:r%r%r&�ls�s�
��zTestInternalScripts.lsc	CsP|��D]!}t|dd��}|��}Wd�n1swYt�|�qdSr()rtr+r,r-r.)r9rr/�datar%r%r&�test_syntax_all�s
��z#TestInternalScripts.test_syntax_allz	not on CIrc	Cs0|��D]}zt|�WqtyYqwdS�N)rtr�
SystemExit)r9rr%r%r&�test_import_all�s��z#TestInternalScripts.test_import_allN)rlrmrnrortrvr7rprqrryr%r%r%r&rr�s
rrzcan't find setup.pyc@s4eZdZdd�Zejje�d�dd�dd��Z	dS)	�TestSetupScriptcCsPtt�}t�t��|��Wd�n1swY|��tjks&J�dSrw)	r�SETUP_PYr7Zraisesrx�setup�get_versionr�__version__)r9�moduler%r%r&�test_invocation�s

�zTestSetupScript.test_invocation�	python2.7zpython2.7 not installedrcCs`tjt�d�tgtjtjdd�}|��\}}|��dksJ�|r"J�d|vs(J�d|vs.J�dS)Nr�T)�stdout�stderr�universal_newlines�z$psutil no longer supports Python 2.7z'Latest version supporting Python 2.7 is)�
subprocess�Popen�shutil�whichr{�PIPE�communicate�wait)r9�pr�r�r%r%r&�test_python2�s�zTestSetupScript.test_python2N)
rlrmrnr�r7rprqr�r�r�r%r%r%r&rz�s�rz)"�__doc__r-rr�r=r�r7rrrZpsutil.testsrrrrrr	r
rrr
rrrrrrsr{rprq�existsrrrrzr%r%r%r&�<module>sP���