MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyc
�
g��fc@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZdefd	��YZd
�Zd�Zd�Zeeededd
d�ZdS(s�
:py:mod:`leapp.libraries.stdlib`
represents a location for functions that otherwise would be defined multiple times across leapp actors
and at the same time, they are really useful for other actors.
i����N(t
LeappError(tcreate_audit_entry(tapi(t_calltSTDOUT(tis_debugtCalledProcessErrorcBsbeZdZd�Zed��Zed��Zed��Zed��Zed��Z	RS(s|
    Leapp Call Process Exception Error.

    Raised when the result of a called process is of a none zero return code.
    cCs,tt|�j|�||_||_dS(s
        Initialize CalledProcessError Exception.
        :param message: An CalledProcessError exception message.
        :param command: The command that has been executed, with its arguments.
        :param result: A non-zero whatever result that the command returned.
        N(tsuperRt__init__t_resulttcommand(tselftmessageR
tresult((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyRs	cCs|jjd�S(sH
        Retrieve the stdout.
        :return: Standard Output.
        tstdout(R	tget(R((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyR$scCs|jjd�S(sG
        Retrieve the stderr.
        :return: Standard Error.
        tstderr(R	R(R((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyR,scCs|jjd�S(sH
        Retrieve the exit code.
        :return: An exit code.
        t	exit_code(R	R(R((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyR4scCs|jjd�S(s~
        Retrieve the signal which the process was signalled by.
        :return: A signal that the process received.
        tsignal(R	R(R((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyR<scCs|jjd�S(sd
        Retrieve the pid of the finished process.
        :return: The pid of the process.
        tpid(R	R(R((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyRDs(
t__name__t
__module__t__doc__RtpropertyRRRRR(((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyRs	cCs�|\}}tjdkr^|tkr9tjj�}ntjj�}tj||g�n/|tkr}tjj|�ntjj|�dS(s
    Raw write to fd compatible in Py2 and Py3 (3.3+)

    Buffer Output Discrimination is based on fd_type in fd_info.

    :param fd_info: Contains File descriptor type
    :type fd_info: tuple
    :param a_buffer: buffer interface
    :type a_buffer: bytes array
    iiN(ii(	tsystversion_infoRRtfilenoRtostwritevtwrite(tfd_infota_buffert	unused_fdtfd_typetfd((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyt__write_rawNscCst�rt||�ndS(s
    Log into either STDOUT or to STDERR.

    Buffer Output Discrimination is based on fd_type in fd_info while in a leapp debug mode.

    :param fd_info: Contains File descriptor type
    :type fd_info: tuple
    :param a_buffer: buffer interface
    :type a_buffer: bytes array
    N(RR#(RR((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyt_console_logging_handleris	cCs�d�}d�}t�r�tj�jj}g|D]}t|tj�r4|^q4}g|D]}|j^q_}||�tj�j	|�|||�ntj�j	|�dS(s�
    Log into logfile

    :param fd_info: Contains File descriptor type (not used)
    :type fd_info: tuple
    :param line: data to be printed to a logfile
    :type line: string
    cSs)x"|D]}|j|jd�qWdS(Ni(tsetLeveltlevel(thandlersthandler((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyt_raise_level�s
cSs1x*t||�D]\}}|j|�qWdS(N(tzipR%(R'tlevelsR(R&((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyt_restore_level�sN(
RRtcurrent_loggertrootR't
isinstancetloggingt
StreamHandlerR&tdebug(RtlineR)R,tlogger_handlersR(tstream_handlersthandler_levels((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyt_logfile_logging_handlerxs				+
sutf-8cCs^|s.d}tj�j|�t|��ntj�jdjt|���ttj��}	i}
z9y�t	di|	d6|d6|d6�t
|d|d|d	|d|d
|�}
|r"|
ddkr"d
jt|�|
jd��}tj�j|�td|d|d|
��n|rO|rO|
j
i|
dj�d6�nWnMtk
r�idd6dd6dd6dd6}
dj|d�|
d<�nXWd|
}|s|
j�}|j
idtj|
d�jd�d6dtj|
d�jd�d6�nt	di|	d6|d6|d6|d6�tj�jdjt|���X|
S(s�
    Run a command and return its result as a dict.

    The execution of the program and it's results are captured by the audit.

    :param args: Command to execute
    :type args: list or tuple
    :param split: Split the output on newlines
    :type split: bool
    :param callback_raw: Optional custom callback executed on raw data to print in console
    :type callback_raw: (fd: int, buffer: bytes) -> None
    :param env: Environment variables to use for execution of the command
    :type env: dict
    :param checked: Raise an exception on a non-zero exit code, default True
    :type checked: bool
    :param stdin: String or a file descriptor that will be written to stdin of the child process
    :type stdin: int, str
    :return: {'stdout' : stdout, 'stderr': stderr, 'signal': signal, 'exit_code': exit_code, 'pid': pid}
    :rtype: dict
    :raises: OSError if an executable is missing or has wrong permissions
    :raises: CalledProcessError if the cmd has non-zero exit code and `checked` is True
    :raises: TypeError if any input parameters have an invalid type
    :raises: valueError if any of input parameters have an invalid value
    sCommand to call is missing.s!External command has started: {0}s
process-starttidt
parameterstenvtcallback_rawtcallback_linebufferedtstdintencodingRis&Command {0} failed with exit code {1}.RR
R
Rt127tRRs'File not found or permission denied: {}RNsBase64: sutf-8sprocess-results"External command has finished: {0}(RR-terrort
ValueErrorR2tformattstrtuuidtuuid4RRRRtupdatet
splitlinestOSErrortcopytbase64t	b64encodetdecode(targstsplitR;R<R:tcheckedR=R>Rt_idR
taudit_result((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pytrun�sH""!	
"	!(&#(RRKR0RRREtleapp.exceptionsRtleapp.utils.auditRtleapp.libraries.stdlibRtleapp.libraries.stdlib.callRRtleapp.libraries.stdlib.configRRR#R$R7tFalsetNonetTrueRS(((sC/usr/lib/python2.7/site-packages/leapp/libraries/stdlib/__init__.pyt<module>s ;