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/output/__pycache__/__init__.cpython-310.pyc
o

�N�g�@s�dZddlZddlZddlZddlZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	e�
e�Zdd�Zdd�Zdd�Zd	d
�Zddd�Zdd
d�Zddd�Zddd�Zddd�Zdd�ZdS)zg
Used to manage the outputter system. This package is the modular system used
for managing outputters.
�Nc
Ks�zt||�|fi|��}|dur|��WSWdStttfyot�t���ztd|�|fi|��}|dur?|��WYSWYdStttfyntj	ddd�td|�|fi|��}|durj|��YYSYYdSww)zx
    Safely get the string to print out, try the configured outputter, then
    fall back to nested and then to raw
    N�nestedzNested output failed: T)�exc_info�raw)
�get_printout�rstrip�KeyError�AttributeError�	TypeError�log�debug�	traceback�
format_exc�error)�data�out�opts�kwargsZprintout�r�H/opt/saltstack/salt/lib/python3.10/site-packages/salt/output/__init__.py�try_printouts(
�����rcCs"tjj||ddd�|�d�|�S)z7
    Get the progress bar from the given outputter
    Z	rawmodule�output)�modz.progress_iter)�salt�loaderZraw_mod)rr�progressrrr�get_progress3s
��rcCsBz
tj�|�|}Wntyt�d�YdSw|||�dS)z>
    Update the progress iterator for the given outputter
    z!Progress outputter not available.FN)rr�
outputtersrr
�warning)rr�
progress_iterrZprogress_outputterrrr�update_progress<s
�rcCs$z|��WdStyYdSw�N)�stop�	Exception)rrrr�progress_endIs
��r#c

Ks4|duri}t|||fi|��}|�dd�}t�d|�zc|rqt|d�s/tjj�|d�}d}n|}d}z5|}t	|t
�rNz|�d�}Wntt
fyMYnw|r_|�tjj�|��|�d	�W|rf|��WdS|rp|��ww|r}tjj�|�WdSWdSty�}	z|	jtjkr��WYd}	~	dSd}	~	ww)
z8
    Print the passed data using the desired output
    NZoutput_filez	data = %s�write�aTFzutf-8�
)r�getr
Ztrace�hasattrr�utils�filesZfopen�
isinstance�str�encode�UnicodeDecodeError�UnicodeEncodeErrorr$ZstringutilsZto_str�closeZ	print_cli�OSError�errnoZEPIPE)
rrrrZdisplay_dataZoutput_filenameZofhZ	fh_openedZfdata�excrrr�display_outputQsN

�
��
�����r4cKsn|duri}d|vr|ddkr|d}|s4|�d�r4|�d�r%|d}n|�dd��d�dd	kr4d}|d
kr;d}n
|dusC|dkrEd}|�d
d�rMd
}|�|�d|vr~dd�}|�dd�red|d<n6|�dd�st|�sttjj��ryd|d<n"d|d<n|�dd�r�d|d<n|�dd�s�tjj��r�d|d<n	tj�|�}||vr�|dkr�t	�
d|�|dS||S)z#
    Return a printer function
    NrZ	highstateZstaticZfun��.r�state�text�txtrrFZcolorc	Ss8ztj��}Wnttjfyd}Ynwt�|�S)z>
            Check if sys.stdout is a pipe or not
            ���)�sys�stdout�filenor�io�UnsupportedOperation�os�isatty)r=rrr�is_pipe�s�zget_printout.<locals>.is_pipeZforce_colorTZno_colorZgrainsz3Invalid outputter %s specified, fall back to nested)r'�split�updaterr)�platformZ
is_windowsrrr
r)rrrrBrrrrr�sT





��
�



�rcKst|||fi|��S)zC
    Return the formatted outputter string for the passed data
    )r)rrrrrrr�
out_format�srFcKs*t|||fi|��}t�d�}|�d|�S)zT
    Return the formatted outputter string, removing the ANSI escape sequences.
    z
\x1b[^m]*mr5)r�re�compile�sub)rrrrZ
raw_outputZansi_escaperrr�
string_format�s
rJcKs(t|||fi|��}|�dd��dd�S)z.
    Return the formatted string as HTML.
    � z&nbsp;r&z<br />)rJ�replace)rrrrZansi_escaped_stringrrr�html_format�srMcCst|t�r|�dd�S|S)z{
    Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings
    from writing their own terminal manipulation commands
    ��?)r+r,rL)r9rrr�strip_esc_sequence�s
rP)NNr )�__doc__r2r>�loggingr@rGr;rZsalt.loaderrZsalt.utils.filesZsalt.utils.platformZsalt.utils.stringutils�	getLogger�__name__r
rrrr#r4rrFrJrMrPrrrr�<module>s.
		

/
H