HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib64/python3.10/site-packages/docker/api/__pycache__/exec_api.cpython-310.pyc
o

�hB�@s.ddlmZmZddlmZGdd�d�ZdS)�)�errors�utils)�CancellableStreamc@sPeZdZe�d�			ddd��Zdd	�Zdd
d�Ze�d�		dd
d��ZdS)�ExecApiMixin�	containerTF�Nc
Cs�|	durt�|jd�rt�d��t|t�rt�|�}t|	t�r%tj�	|	�}	|||||||||	d�	}|
durEt�|jd�rAt�d��|
|d<|rL||d<nd|j
vrX|j
d|d<|�d	|�}
|j|
|d
�}|�
|d�S)aC
        Sets up an exec instance in a running container.

        Args:
            container (str): Target container where exec instance will be
                created
            cmd (str or list): Command to be executed
            stdout (bool): Attach to stdout. Default: ``True``
            stderr (bool): Attach to stderr. Default: ``True``
            stdin (bool): Attach to stdin. Default: ``False``
            tty (bool): Allocate a pseudo-TTY. Default: False
            privileged (bool): Run as privileged.
            user (str): User to execute command as. Default: root
            environment (dict or list): A dictionary or a list of strings in
                the following format ``["PASSWORD=xxx"]`` or
                ``{"PASSWORD": "xxx"}``.
            workdir (str): Path to working directory for this exec session
            detach_keys (str): Override the key sequence for detaching
                a container. Format is a single character `[a-Z]`
                or `ctrl-<value>` where `<value>` is one of:
                `a-z`, `@`, `^`, `[`, `,` or `_`.
                ~/.docker/config.json is used by default.

        Returns:
            (dict): A dictionary with an exec ``Id`` key.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        Nz1.25z;Setting environment for exec is not supported in API < 1.25)	�	Container�User�
Privileged�Tty�AttachStdin�AttachStdout�AttachStderr�Cmd�Envz1.35z/workdir is not supported for API version < 1.35�
WorkingDir�
detachKeysz/containers/{0}/exec)�dataT)r�
version_lt�_versionr�InvalidVersion�
isinstance�str�
split_command�dict�format_environment�_general_configs�_url�
_post_json�_result)�selfr�cmd�stdout�stderr�stdin�tty�
privileged�user�environment�workdir�detach_keysr�url�res�r-�F/usr/local/CyberCP/lib/python3.10/site-packages/docker/api/exec_api.py�exec_creates>#�


��

zExecApiMixin.exec_createcCs2t|t�r
|�d�}|�|�d|��}|�|d�S)aL
        Return low-level information about an exec command.

        Args:
            exec_id (str): ID of the exec instance

        Returns:
            (dict): Dictionary of values returned by the endpoint.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        �Idz/exec/{0}/jsonT)rr�get�_getrr)r �exec_idr,r-r-r.�exec_inspectPs

zExecApiMixin.exec_inspectcCsFt|t�r
|�d�}||d�}|�d|�}|j||d�}|�|�dS)z�
        Resize the tty session used by the specified exec command.

        Args:
            exec_id (str): ID of the exec instance
            height (int): Height of tty session
            width (int): Width of tty session
        r0)�h�wz/exec/{0}/resize)�paramsN)rrr1r�_post�_raise_for_status)r r3�height�widthr7r+r,r-r-r.�exec_resizecs



zExecApiMixin.exec_resizer3cCs�||d�}|r	inddd�}|j|�d|�||dd�}	|r-z
|�|	�W|	��S|	��w|r4|�|	�S|j|	|||d�}
|rDt|
|	�S|
S)	a?
        Start a previously set up exec instance.

        Args:
            exec_id (str): ID of the exec instance
            detach (bool): If true, detach from the exec command.
                Default: False
            tty (bool): Allocate a pseudo-TTY. Default: False
            stream (bool): Return response data progressively as an iterator
                of strings, rather than a single string.
            socket (bool): Return the connection socket to allow custom
                read/write operations. Must be closed by the caller when done.
            demux (bool): Return stdout and stderr separately

        Returns:

            (generator or str or tuple): If ``stream=True``, a generator
            yielding response chunks. If ``socket=True``, a socket object for
            the connection. A string containing response data otherwise. If
            ``demux=True``, a tuple with two elements of type byte: stdout and
            stderr.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )r�Detach�Upgrade�tcp)�
Connectionr>z/exec/{0}/startT)�headersr�stream)r%�demux)rrr�close�_get_raw_response_socket�_read_from_socketr)r r3�detachr%rB�socketrCrrAr,�outputr-r-r.�
exec_startus. ��
�


zExecApiMixin.exec_start)	TTFFFrNNN)NN)FFFFF)	�__name__�
__module__�__qualname__r�check_resourcer/r4r<rJr-r-r-r.rs�I
�rN)rrr�typesrrr-r-r-r.�<module>s