Ë
    €ÏP  ã                   ó<   — d dl mZ d dl mZ d dlmZ  G d„ d«      Zy)é   )Úerrors)Úutils)ÚCancellableStreamc                   óˆ   — e Zd Z ej                  d«      	 	 	 dd„«       Zd„ Zd	d„Z ej                  d«      	 	 d
d„«       Zy)ÚExecApiMixinÚ	containerNc           
      óf  — |	5t        j                  | j                  d«      rt        j                  d«      ‚t        |t        «      rt        j                  |«      }t        |	t        «      rt         j                   j                  |	«      }	|||||||||	dœ	}|
:t        j                  | j                  d«      rt        j                  d«      ‚|
|d<   |r||d<   n d| j                  v r| j                  d   |d<   | j                  d|«      }| j                  ||¬	«      }| j                  |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.
        z1.25z;Setting environment for exec is not supported in API < 1.25)	Ú	ContainerÚUserÚ
PrivilegedÚTtyÚAttachStdinÚAttachStdoutÚAttachStderrÚCmdÚEnvz1.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Úress                  ú&lib/third_party/docker/api/exec_api.pyÚexec_createzExecApiMixin.exec_create   s4  € ðF Ð"¤u×'7Ñ'7¸¿¹ÀvÔ'NÜ×'Ñ'ØMóð ô cœ3ÔÜ×%Ñ% cÓ*ˆCäk¤4Ô(ÜŸ+™+×8Ñ8¸ÓEˆKð #ØØ$ØØ Ø"Ø"ØØñ

ˆð ÐÜ×Ñ §¡¨vÔ6Ü×+Ñ+ØEóð ð ")ˆDÑáØ!,ˆDÒØ˜T×2Ñ2Ñ2Ø!%×!6Ñ!6°|Ñ!DˆDÑài‰iÐ.°	Ó:ˆØo‰o˜c¨ˆoÓ-ˆØ|‰|˜C Ó&Ð&ó    c                 óª   — t        |t        «      r|j                  d«      }| j                  | j	                  d|«      «      }| j                  |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)r   r   ÚgetÚ_getr   r!   )r"   Úexec_idr.   s      r/   Úexec_inspectzExecApiMixin.exec_inspectQ   sG   € ô gœtÔ$Ø—k‘k $Ó'ˆGØi‰i˜Ÿ	™	Ð"2°GÓ<Ó=ˆØ|‰|˜C Ó&Ð&r1   c                 ó¼   — t        |t        «      r|j                  d«      }||dœ}| j                  d|«      }| j	                  ||¬«      }| j                  |«       y)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
        r3   )ÚhÚwz/exec/{0}/resize)ÚparamsN)r   r   r4   r   Ú_postÚ_raise_for_status)r"   r6   ÚheightÚwidthr;   r-   r.   s          r/   Úexec_resizezExecApiMixin.exec_resized   sW   € ô gœtÔ$Ø—k‘k $Ó'ˆGà EÑ*ˆØi‰iÐ*¨GÓ4ˆØj‰j˜ VˆjÓ,ˆØ×Ñ˜sÕ#r1   r6   c                 óJ  — ||dœ}|ri ndddœ}| j                  | j                  d|«      ||d¬«      }	|r"	 | j                  |	«      |	j                  «        S |r| j	                  |	«      S | j                  |	|||¬«      }
|rt        |
|	«      S |
S # |	j                  «        w xY w)	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)Ú
ConnectionrC   z/exec/{0}/startT)Úheadersr   Ústream)r'   Údemux)r    r   r!   ÚcloseÚ_get_raw_response_socketÚ_read_from_socketr   )r"   r6   Údetachr'   rG   ÚsocketrH   r   rF   r.   Úoutputs              r/   Ú
exec_startzExecApiMixin.exec_startv   sÁ   € ð@ Øñ
ˆñ
 ‘"Ø#Øñ%
ˆð
 o‰oØI‰IÐ'¨Ó1ØØØð	 ó 
ˆñ ðØ—|‘| CÓ(à—	‘	•ÙØ×0Ñ0°Ó5Ð5à×'Ñ'¨¨V¸ÀEÐ'ÓJˆÙÜ$ V¨SÓ1Ð1àˆMøð —	‘	•ús   ·B ÂB")	TTFFFÚ NNN)NN)FFFFF)	Ú__name__Ú
__module__Ú__qualname__r   Úcheck_resourcer0   r7   r@   rO   © r1   r/   r   r      s^   „ Ø€U×Ñ˜+Ó&Ø>BØCEØ@DòG'ó 'ðG'òR'ó&$ð$ €U×Ñ˜)Ó$ØBGØ',ò:ó %ñ:r1   r   N)rP   r   r   Útypesr   r   rU   r1   r/   Ú<module>rW      s   ðÝ Ý Ý %÷kò kr1   