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/lib/python3.10/site-packages/docker/utils/__pycache__/socket.cpython-310.pyc
o

�h��@s�ddlZddlZddlZddlZddlZzddlmZWn
ey)e	d�ZYnwdZ
dZGdd�de�Z
dZdd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zddd�Zdd�ZdS)�N�)�NpipeSocket�c@seZdZdS)�SocketErrorN)�__name__�
__module__�__qualname__�r	r	�F/usr/local/CyberCP/lib/python3.10/site-packages/docker/utils/socket.pyrsr�m�c
Cstjtjtjf}t|t�s-ttd�st�|ggg�nt��}|�	|tj
tjB�|��z t|d�r9|�|�WSt|t
j�rE|�|�WSt�|��|�WStyf}z
|j|vr[�WYd}~dSd}~wty�}zt|t�ot|j�dko|jdtk}|r�WYd}~dS�d}~ww)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_endedr	r	r
rs:



��
����rcCsFd}t|�|kr!t||t|��}|std��||7}t|�|ks|S)z]
    Reads exactly n bytes from socket
    Raises SocketError if there isn't enough data
    �zUnexpected EOF)r!rr)r$r%�data�	next_datar	r	r
�read_exactly>s�r,cCs<zt|d�}Wn
tyYdSwt�d|�\}}||fS)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
    �)���r.z>BxxxL)r,r�struct�unpack)r$r*�stream�actualr	r	r
�next_frame_headerLs�r3cCs|rdd�t|�D�St|�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.
    css�|]}t|fVqdS)N)�STDOUT)�.0�framer	r	r
�	<genexpr>es�zframes_iter.<locals>.<genexpr>)�frames_iter_tty�frames_iter_no_tty)r$�ttyr	r	r
�frames_iter\sr;ccsh�	t|�\}}|dkrdS|dkr3t||�}|durqt|�}|dkr&dS||8}||fV|dksq)zc
    Returns a generator of data read from the socket when the tty setting is
    not enabled.
    TrN)r3rr!)r$r1r%�result�data_lengthr	r	r
r9js �

��r9ccs$�	t|�}t|�dkrdS|Vq)z^
    Return a generator of data read from the socket when the tty setting is
    enabled.
    TrN)rr!)r$r<r	r	r
r8s��r8FcCs�|dur	d�|�Sddg}|D]=}|dksJ�|ddur5|ddur*|d|d<q|d|d7<q|ddurB|d|d<q|d|d7<qt|�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)NNrr)�join�tuple)�frames�demux�outr6r	r	r
�consume_socket_output�s
rCcCs.|tkr|dfS|tkrd|fSt|�d���)z[
    Utility to demultiplex stdout and stderr when reading frames from the
    socket.
    Nz is not a valid stream)r4�STDERR�
ValueError)�	stream_idr*r	r	r
�
demux_adaptor�s
rG)r)F)rrrr$rr/�	transportr�ImportError�typer4rDr rr#rr,r3r;r9r8rCrGr	r	r	r
�<module>s,�
$

%