}Ce ZddlmZddlZddlZddlZGddeZdZd dZd Z dS) )absolute_importNc eZdZdZddefdZdS)ExternalProgramFailedzCException class for errors related to externally executed commands.messagec<t||dS)N) Exception__init__)selfrs /builddir/build/BUILDROOT/alt-python27-cllib-3.3.7-2.el7.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/utils_cmd.pyr zExternalProgramFailed.__init__s4)))))N)r)__name__ __module__ __qualname____doc__strr r r rr s:MM********r rctj|s)td|dt jddSdS)z6 Checks if command is present and exits if no zCommand not found: ()N)ospathexistsprintsysexit)cmdnames r check_commandrsO 7>>' " " /W///000  r FTc 6d|} |r tjn tj}|r tjn tj}tj||tj|d||}n4#t $r'} t|dt| | d} ~ wwxYw|s| \} } n| |\} } |r |j | | fS|j 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)stdinstdoutstderr close_fdsenvtextz. Cannot run command: Nrz Error during command execution: zoutput of the command:  ) join subprocessPIPESTDOUTDEVNULLPopenOSErrorrr communicate returncode) cmdenv_datareturn_full_outputstd_inconvert_to_strcmd_line std_err_obj stdin_argoutputoserrstd_outstd_errs r run_commandr=sixx}}H);RjooAR '-EJOO:3E ! ?    # ; ;s5zz ; ;    6!--//!--f553 '722 A '(U8(U(UVV V'PPhhhP  NsAA11 B";"BB"ct}||||tj|tjd}|\}}|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)r"r&) listappendextendr)r-r*r/r0strip) util_pathparamsargsprocessr"_retcodes r exec_utilityrIFsz 66DKK KKtJO$GGGG##%%IFA G FLLNN ""r )NFNT) __future__rrrr)r rrr=rIrr r rKs'&&&&& *****I*** ''''T # # # # #r