HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/profile.cpython-310.pyc
o

�N�g��@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
Ze�e�Z
zddlZdZWney>dZYnwddd�Zd
dd�Zdd
d�ZdS)z8
Decorator and functions to profile Salt using cProfile
�NTFcs�fdd�}|S)zE
    Decorator for adding profiling to a nested function in Salt
    cs��fdd�}|S)Ncslt�d�j�zt��}|j�g|�Ri|��}|��p!�j�d��W|Sty5t�d��Y|Sw)NzProfiling function %sz
_func.profilezCould not open profile file %s)	�logging�info�__name__�cProfile�ProfileZruncall�
dump_stats�OSError�	exception)�args�kwargsZprofiler�retval)�filename�fun��F/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/profile.py�
profiled_func s��z5profile_func.<locals>.proffunc.<locals>.profiled_funcr)rr�r
)rr�proffuncszprofile_func.<locals>.proffuncr)r
rrrr�profile_funcsrcCs.d}|rtrt��}|��|St�d�|S)Nz*cProfile is not available on your platform)�HAS_CPROFILErr�enable�log�error)�test�prrrr�activate_profile0s
�r�
/tmp/statsc
Cs|dur�tr�z�|��tj�|�st�|�tj����}|dur)t	j
jjdd�}tj�
||�d|�d��}tj�
||�d|�d��}tj�
||�d|�d��}tj�|�s}|�|�t	j
j�|d��}tj||d��d	�Wd�n1sxwYt�d
|�t�d|�t	j
j�d�}	|	d
|d|g}
|	r�d}z
tj|
dtjtjd�}Wnty�d}Ynw|jr�d}|r�t�d�nt�d|�t�d�t�t	j
j� |j!�"���#�t	j
j� |j$�"���#��nt�d|
�W|s�|�%�|S|s�|�%�ww|S)N� )�size�.z.pstatsz.dotz.stats�w)�streamZ
cumulativezPROFILING: %s generatedz$PROFILING (cumulative): %s generatedZpyprof2calltreez-iz-oF)�shell�stdout�stderrTzPROFILING (dot problemzPROFILING (dot): %s generatedzpyprof2calltree output:z$You can run %s for additional stats.)&r�disable�os�path�isdir�makedirs�datetime�now�	isoformat�salt�utilsZ	hashutilsZrandom_hash�join�existsr�filesZfopen�pstatsZStatsZ
sort_statsrr�which�
subprocess�Popen�PIPEr�
returncoderZtraceZstringutilsZto_strr#�read�stripr$r)
rZ
stats_path�stopZid_�dateZficpZficoZficnZficZpyprof�cmdZfailedZprorrr�output_profile;sb

�
��
����
�r=)N)T)rFN)�__doc__r*rr&r2r4Zsalt.utils.filesr-Zsalt.utils.hashutilsZsalt.utils.pathZsalt.utils.stringutils�	getLoggerrrrr�ImportErrorrrr=rrrr�<module>s(
�