Your IP : 3.21.44.115


Current Path : /opt/imunify360/venv/lib64/python3.11/site-packages/clcommon/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib64/python3.11/site-packages/clcommon/__pycache__/utils_cmd.cpython-311.pyc

�

\�Dg�
��N�ddlZddlZddlZGd�de��Zd�Zd	d�Zd�ZdS)
�Nc� �eZdZdZddefd�ZdS)�ExternalProgramFailedzCException class for errors related to externally executed commands.��messagec�<�t�||��dS)N)�	Exception�__init__)�selfrs  �r/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/utils_cmd.pyr	zExternalProgramFailed.__init__s�����4��)�)�)�)�)�N)r)�__name__�
__module__�__qualname__�__doc__�strr	�rrrrs:������M�M�*�*��*�*�*�*�*�*rrc��tj�|��s)td|�d���t	jd��dSdS)z6
    Checks if command is present and exits if no
    zCommand not found: (�)�N)�os�path�exists�print�sys�exit)�cmdnames r�
check_commandrsO���7�>�>�'�"�"��
�/�W�/�/�/�0�0�0����������rFTc	�`�d�|��}	|rtjntj}|rtjntj}tj||tj|d||���5}|s|���\}	}
n|�|��\}	}
|j}ddd��n#1swxYwYn4#t$r'}t|�dt|������|�d}~wwxYw|r||	|
fS|dkr+|std|�����t|
pd|�d	|	�����|	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�stderr�	close_fds�env�textNz. Cannot run command: rz Error during command execution: zoutput of the command: �
)�join�
subprocess�PIPE�STDOUT�DEVNULL�Popen�communicate�
returncode�OSErrorrr)
�cmd�env_data�return_full_output�std_in�convert_to_str�cmd_line�std_err_obj�	stdin_arg�proc�std_out�std_errr.�oserrs
             r�run_commandr<s����x�x��}�}�H��);�R�j�o�o��AR��'-�E�J�O�O�:�3E�	�
�
����?�����
�
�
�
	)���
<�#'�#3�#3�#5�#5� ����#'�#3�#3�F�#;�#;� �����J�
	)�
	)�
	)�
	)�
	)�
	)�
	)�
	)�
	)�
	)�
	)����
	)�
	)�
	)�
	)�������#��;�;�s�5�z�z�;�;�
�
��	���������
�,��7�G�+�+��Q����	�'�(U�8�(U�(U�V�V�V�'��J�J�X�J�J��J�J���
��Ns<�AC�0:B6�*C�6B:�:C�=B:�>C�
C3�"C.�.C3c�4�g}|�|��|�|��tj|tjd���5}|���\}}|j}ddd��n#1swxYwY||���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)r!r%N)�append�extendr(r,r)r-r.�strip)�	util_path�params�argsr8r!�_�retcodes       r�exec_utilityrFGs����D��K�K�	�����K�K�����	�	�$�z��T�	B�	B�	B�"�d��$�$�&�&�	����/��"�"�"�"�"�"�"�"�"�"�"����"�"�"�"��F�L�L�N�N�"�"s�A9�9A=�A=)NFNT)rrr(rrrr<rFrrr�<module>rGs���
�	�	�	�
�
�
�
�����*�*�*�*�*�I�*�*�*����)�)�)�)�X
#�
#�
#�
#�
#r

?>