����JFIF���������
1#@!#!123s
D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
lib
/
python2.7
/
site-packages
/
leapp
/
libraries
/
stdlib
/
__pycache__
/
Filename :
__init__.cpython-36.pyc
back
Copy
3 �S4b;������������������@���s����d�Z�ddlZddlZddlZddlZddlZddlmZ�ddlm Z �ddl mZ�ddlm Z mZ�ddlmZ�G�dd ��d e�Zd d��Zdd ��Zdd��Zdeeddddfdd�ZdS�)z� :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. �����N)� LeappError)�create_audit_entry)�api)�_call�STDOUT)�is_debugc�������������������s\���e�Zd�ZdZ��fdd�Zedd���Zedd���Zedd ���Zed d���Z edd ���Z ���ZS�)�CalledProcessErrorz| Leapp Call Process Exception Error. Raised when the result of a called process is of a none zero return code. c����������������s ���t�t|��j|��||�_||�_dS�)a�� 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)�superr����__init__�_result�command)�self�messager����result)� __class__���6/root/tmp_leapp_py3/leapp/libraries/stdlib/__init__.pyr ������s����zCalledProcessError.__init__c�������������C���s���|�j�jd�S�)zH Retrieve the stdout. :return: Standard Output. �stdout)r����get)r ���r���r���r���r���$���s����zCalledProcessError.stdoutc�������������C���s���|�j�jd�S�)zG Retrieve the stderr. :return: Standard Error. �stderr)r���r���)r ���r���r���r���r���,���s����zCalledProcessError.stderrc�������������C���s���|�j�jd�S�)zH Retrieve the exit code. :return: An exit code. � exit_code)r���r���)r ���r���r���r���r���4���s����zCalledProcessError.exit_codec�������������C���s���|�j�jd�S�)z~ Retrieve the signal which the process was signalled by. :return: A signal that the process received. �signal)r���r���)r ���r���r���r���r���<���s����zCalledProcessError.signalc�������������C���s���|�j�jd�S�)zd Retrieve the pid of the finished process. :return: The pid of the process. �pid)r���r���)r ���r���r���r���r���D���s����zCalledProcessError.pid)�__name__� __module__�__qualname__�__doc__r ����propertyr���r���r���r���r���� __classcell__r���r���)r���r���r������s���r���c�������������C���sf���|�\}}t�jdkr@|tkr&t�jj��}n t�jj��}tj||g��n"|tkrVt�jj|��nt�jj|��dS�)a�� 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 ����r���N)r���r���) �sys�version_infor���r����filenor����os�writev�write)�fd_info�a_bufferZ unused_fdZfd_type�fdr���r���r����__write_rawN���s���� r)���c�������������C���s���t���rt|�|��dS�)a�� 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)r���r)���)r&���r'���r���r���r����_console_logging_handleri���s����r*���c�������������C���sr���dd��}dd��}t���r`tj��jj}dd��|D��}dd��|D��}||��tj��j|��|||��ntj��j|��dS�) z� 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 c�������������S���s"���x|�D�]}|j�|jd���qW�d�S�)N����)�setLevel�level)�handlers�handlerr���r���r����_raise_level����s���� z._logfile_logging_handler.<locals>._raise_levelc�������������S���s&���x t�|�|�D�]\}}|j|��qW�d�S�)N)�zipr,���)r.���Zlevelsr/���r-���r���r���r����_restore_level����s����z0_logfile_logging_handler.<locals>._restore_levelc�������������S���s���g�|�]}t�|tj�r|�qS�r���)� isinstance�logging� StreamHandler)�.0r/���r���r���r���� <listcomp>����s����z,_logfile_logging_handler.<locals>.<listcomp>c�������������S���s���g�|�] }|j��qS�r���)r-���)r6���r/���r���r���r���r7�������s����N)r���r����current_logger�rootr.����debug)r&����liner0���r2���Zlogger_handlersZstream_handlersZhandler_levelsr���r���r����_logfile_logging_handlerx���s���� r<���FTzutf-8c�������������C���sN��|�sd}t�j��j|��t|��t�j��jdjt|�����ttj���} d} z�t d| |�|d���t |�|||||d�} |r�| d�dkr�d jt|��| jd��}t�j��j|��t||�| d ��|r�|r�| j d| d�j��i��W�d| }|�s| j��}|j dtj| d��jd ��dtj| d��jd ��d���t d| |�||d���t�j��jdjt|�����X�| S�)aZ�� 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 zCommand to call is missing.z!External command has started: {0}Nz process-start)�id� parameters�env)�callback_raw�callback_linebuffered�stdinr?����encodingr���r���z&Command {0} failed with exit code {1}.)r���r���r���r���zBase64: zutf-8r���)r���r���zprocess-result)r=���r>���r���r?���z"External command has finished: {0})r���r8����error� ValueErrorr:����format�str�uuid�uuid4r���r���r���r����update� splitlines�copy�base64� b64encode�decode)�args�splitr@���rA���r?����checkedrB���rC���r���Z_idr���Zaudit_resultr���r���r����run����s>����rS���)r���r4���r#���r ���rH���rM����leapp.exceptionsr����leapp.utils.auditr���Zleapp.libraries.stdlibr����leapp.libraries.stdlib.callr���r���Zleapp.libraries.stdlib.configr���r���r)���r*���r<���rS���r���r���r���r����<module>���s ���;