Ë
    9àiÑ  ã                   ó¶   — d dl Z d dlZd dlZd dlZd dlZ	 ddlmZ dZ
dZ G d„ de«      ZdZdd„Zd	„ Zd
„ Zd„ Zd„ Zd„ Zdd„Zd„ Zy# e$ r  e	d«      ZY Œ;w xY w)é    Né   )ÚNpipeSocketé   c                   ó   — e Zd Zy)ÚSocketErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    úT/home/factor_ks/STREAMA2026/venv/lib/python3.12/site-packages/docker/utils/socket.pyr   r      s   „ Ør   r   ém   c                 óL  — t         j                  t         j                  t         j                  f}t	        | t
        «      s~t        t        d«      st        j                  | gg g «       nUt        j                  «       }|j                  | t        j                  t        j                  z  «       |j                  «        	 t        | d«      r| j                  |«      S t	        | t        j                  «      r| j                  |«      S t!        j                  | j#                  «       |«      S # t$        $ r}|j                   |vr‚ Y d}~yd}~wt&        $ rO}t	        | t
        «      xr0 t)        |j*                  «      dkD  xr |j*                  d   t,        k(  }|rY d}~y‚ d}~ww xY w)z+
    Reads at most n bytes from socket
    ÚpollÚrecvNr   Ú )ÚerrnoÚEINTRÚEDEADLKÚEWOULDBLOCKÚ
isinstancer   ÚhasattrÚselectr   ÚregisterÚPOLLINÚPOLLPRIr   ÚpysocketÚSocketIOÚreadÚosÚfilenoÚOSErrorÚ	ExceptionÚlenÚargsÚNPIPE_ENDED)ÚsocketÚnÚrecoverable_errorsr   ÚeÚis_pipe_endeds         r   r   r      s9  € ô
  Ÿ+™+¤u§}¡}´e×6GÑ6GÐHÐä�fœkÔ*Ü”v˜vÔ&ä�M‰M˜6˜( B¨Õ+ä—;‘;“=ˆDØ�M‰M˜&¤&§-¡-´&·.±.Ñ"@ÔAØ�I‰IŒKðÜ�6˜6Ô"Ø—;‘;˜q“>Ð!Ü�fœh×/Ñ/Ô0Ø—;‘;˜q“>Ð!Ü�w‰w�v—}‘}“¨Ó*Ð*øÜò Ø�7‰7Ð,Ñ,Øô -ûäò Ü# F¬KÓ8ò 2Ü˜QŸV™V› q™ò2àŸ™ ™¤kÑ1ð 	ñ ô Øûðús7   Â?D+ Ã*D+ Ä#D+ Ä+	F#Ä4EÅF#ÅAFÆFÆF#c                 ó˜   — d}t        |«      |k  r9t        | |t        |«      z
  «      }|st        d«      ‚||z  }t        |«      |k  rŒ9|S )z]
    Reads exactly n bytes from socket
    Raises SocketError if there isn't enough data
    r   zUnexpected EOF)r$   r   r   )r'   r(   ÚdataÚ	next_datas       r   Úread_exactlyr/   >   sU   € ð
 €DÜ
ˆd‹)�aŠ-Ü˜ ¤S¨£Y¡Ó/ˆ	ÙÜÐ.Ó/Ð/Ø�	Ñˆô	 ˆd‹)�a‹-ð
 €Kr   c                 ót   — 	 t        | d«      }t        j                  d|«      \  }}||fS # t        $ r Y yw xY w)zÐ
    Returns the stream and size of the next frame of data waiting to be read
    from socket, according to the protocol defined here:

    https://docs.docker.com/engine/api/v1.24/#attach-to-a-container
    é   )éÿÿÿÿr2   z>BxxxL)r/   r   ÚstructÚunpack)r'   r-   ÚstreamÚactuals       r   Únext_frame_headerr7   L   sH   € ðÜ˜F AÓ&ˆô —]‘] 8¨TÓ2�N€FˆFØ�FÐÐøô	 ò Ùðús   ‚+ «	7¶7c                 ó@   — |rd„ t        | «      D «       S t        | «      S )zý
    Return a generator of frames read from socket. A frame is a tuple where
    the first item is the stream number and the second item is a chunk of data.

    If the tty setting is enabled, the streams are multiplexed into the stdout
    stream.
    c              3   ó,   K  — | ]  }t         |f–— Œ y ­w)N)ÚSTDOUT)Ú.0Úframes     r   ú	<genexpr>zframes_iter.<locals>.<genexpr>e   s   è ø€ ÒE E”˜”ÑEùs   ‚)Úframes_iter_ttyÚframes_iter_no_tty)r'   Úttys     r   Úframes_iterrA   \   s"   € ñ ÙE¬_¸VÓ-DÔEÐEä! &Ó)Ð)r   c              #   ó¢   K  — 	 t        | «      \  }}|dk  ry|dkD  r1t        | |«      }|€Œt        |«      }|dk(  ry||z  }||f–— |dkD  rŒ1ŒK­w)zc
    Returns a generator of data read from the socket when the tty setting is
    not enabled.
    r   N)r7   r   r$   )r'   r5   r(   ÚresultÚdata_lengths        r   r?   r?   j   st   è ø€ ð
 Ü'¨Ó/‰ˆ�ØˆqŠ5ØØ�!ŠeÜ˜& !“_ˆFØˆ~ØÜ˜f›+ˆKØ˜aÒàØ�ÑˆAØ˜6Ð"Ò"ð �!‹eð	 ùs   ‚AAÁAc              #   óJ   K  — 	 t        | «      }t        |«      dk(  ry|–— Œ­w)z^
    Return a generator of data read from the socket when the tty setting is
    enabled.
    r   N)r   r$   )r'   rC   s     r   r>   r>      s-   è ø€ ð
 Ü�f“ˆÜˆv‹;˜!ÒàØŠð ùs   ‚!#c                 óê   — |du rdj                  | «      S ddg}| D ]K  }|dk7  sJ ‚|d   �|d   €	|d   |d<   Œ|dxx   |d   z  cc<   Œ.|d   €	|d   |d<   Œ<|dxx   |d   z  cc<   ŒM t        |«      S )a“  
    Iterate through frames read from the socket and return the result.

    Args:

        demux (bool):
            If False, stdout and stderr are multiplexed, and the result is the
            concatenation of all the frames. If True, the streams are
            demultiplexed, and the result is a 2-tuple where each item is the
            concatenation of frames belonging to the same stream.
    Fr   N)NNr   r   )ÚjoinÚtuple)ÚframesÚdemuxÚoutr<   s       r   Úconsume_socket_outputrL   Œ   s¬   € ð ��~ð �x‰x˜ÓÐð �ˆ,€CØò #ˆð ˜Ò$Ð$Ð$Ø�‰8ÐØ�1‰vˆ~Ø˜q™��A’à�A“˜% ™(Ñ"”à�1‰vˆ~Ø˜q™��A’à�A“˜% ™(Ñ"”ð#ô �‹:Ðr   c                 óR   — | t         k(  r|dfS | t        k(  rd|fS t        | › d�«      ‚)z[
    Utility to demultiplex stdout and stderr when reading frames from the
    socket.
    Nz is not a valid stream)r:   ÚSTDERRÚ
ValueError)Ú	stream_idr-   s     r   Údemux_adaptorrQ   ±   s;   € ð
 ”FÒØ�dˆ|ÐØ	”fÒ	Ø�dˆ|Ðä˜I˜;Ð&<Ð=Ó>Ð>r   )i   )F)r   r    r   r'   r   r3   Ú	transportr   ÚImportErrorÚtyper:   rN   r#   r   r&   r   r/   r7   rA   r?   r>   rL   rQ   r   r   r   ú<module>rU      s€   ðÛ Û 	Û Û Û ðÝ'ð
 
€Ø	
€ô	�)ô 	ð €ó!òHòò *ò#ò*
ó"óJ
?øðQ ò Ù�t“*‚Kðús   –A ÁAÁA