HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/clcommon/__pycache__/utils_cmd.cpython-37.opt-1.pyc
B

��rj|X�@sRddlmZddlZddlZddlZGdd�de�Zdd�Zd
d	d
�Zdd�Z	dS)�)�absolute_importNc@s eZdZdZded�dd�ZdS)�ExternalProgramFailedzCException class for errors related to externally executed commands.�)�messagecCst�||�dS)N)�	Exception�__init__)�selfr�r	��/builddir/build/BUILDROOT/alt-python27-cllib-3.4.1-1.el9.cloudlinux.x86_64/opt/alt/python37/lib/python3.7/site-packages/clcommon/utils_cmd.pyrszExternalProgramFailed.__init__N)r)�__name__�
__module__�__qualname__�__doc__�strrr	r	r	r
r
srcCs*tj�|�s&td|�d��t�d�dS)z6
    Checks if command is present and exits if no
    zCommand not found: (�)�N)�os�path�exists�print�sys�exit)Zcmdnamer	r	r
�
check_commandsrFTc
Cs�d�|�}y>|rtjntj}|r&tjntj}tj||tj|d||d�}Wn:tk
r�}	zt|�dt|	����|	�Wdd}	~	XYnX|s�|�	�\}
}n|�	|�\}
}|r�|j
|
|fS|j
dkr�|s�td|����nt|p�d||
f��|
S)	a[
    Runs external process and returns output
    :param cmd: command and arguments as a list
    :param env_data: environment data for process
    :param return_full_output: if true, returns (ret_code, std_out, std_err)
    @return: process stdout if is_full_output==False
    else - cortege (ret_code, std_out, std_err) without any checking
    � T)�stdin�stdout�stderrZ	close_fds�env�textz. Cannot run command: Nrz Error during command execution: zoutput of the command: %s
%s)�join�
subprocess�PIPEZSTDOUTZDEVNULL�Popen�OSErrorrr�communicate�
returncode)�cmdZenv_dataZreturn_full_outputZstd_inZconvert_to_strZcmd_lineZstd_err_objZ	stdin_arg�outputZoserrZstd_outZstd_errr	r	r
�run_commands6	

r(cCsJt�}|�|�|�|�tj|tjdd�}|��\}}|j}||��fS)z�
    Executes supplied utility with supplied parameters
    :param util_path: Executable file to run path
    :param params: utility parameters
    :return: Cortege (ret_code, utility_stdout)
    T)rr)	�list�append�extendr r"r!r$r%�strip)Z	util_pathZparams�argsZprocessr�_Zretcoder	r	r
�exec_utilityFs

r/)NFNT)
Z
__future__rrrr rrrr(r/r	r	r	r
�<module>s	
*