%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pexpect/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pexpect/__pycache__/socket_pexpect.cpython-312.pyc

�

��e���T�dZddlZddlmZddlmZmZddlmZdgZ	Gd�de�Z
y)	a,This is like :mod:`pexpect`, but it will work with any socket that you
pass it. You are responsible for opening and closing the socket.

PEXPECT LICENSE

    This license is approved by the OSI and FSF as GPL-compatible.
        http://opensource.org/licenses/isc-license.txt

    Copyright (c) 2012, Noah Spurrier <noah@noah.org>
    PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY
    PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE
    COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES.
    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

�N)�contextmanager�)�TIMEOUT�EOF)�	SpawnBase�SocketSpawnc��eZdZdZ								ddejfd�Zd�Zd�Zdefd�Z	defd	�Z
d
�Zd�Ze
d��Zdd
�Zy)rz�This is like :mod:`pexpect.fdpexpect` but uses the cross-platform python socket api,
    rather than the unix-specific file descriptor api. Thus, it works with
    remote connections on both unix and windows.N�socketc
	���d|_d|_tj|||||||��||_|j
�|_d|_d|z|_|	|_	y)zThis takes an open socket.N)�encoding�codec_errorsFz<socket %s>)
�args�commandr�__init__r
�fileno�child_fd�closed�name�use_poll)
�selfr
r�timeout�maxread�searchwindowsize�logfilerr
rs
          �8/usr/lib/python3/dist-packages/pexpect/socket_pexpect.pyrzSocketSpawn.__init__%sg����	�������������%�	
����%��
�
���
����!�F�*��	� ��
�c���|jdk(ry|j�|jjtj�|jj�d|_d|_y)z�Close the socket.

        Calling this method a second time does nothing, but if the file
        descriptor was closed elsewhere, :class:`OSError` will be raised.
        ���NT)r�flushr
�shutdown�	SHUT_RDWR�closer�rs rr"zSocketSpawn.closeDsR���=�=�B����
�
�������V�-�-�.���������
���rc�<�|jj�dk\S)z Alive if the fileno is valid r)r
rr#s r�isalivezSocketSpawn.isaliveSs���{�{�!�!�#�q�(�(r�returnc���|j|�}|j|d�|jj|d��}|jj|�t
|�S)z/Write to socket, return number of bytes written�sendF)�final)�_coerce_send_string�_log�_encoder�encoder
�sendall�len)r�s�bs   rr(zSocketSpawn.sendWsT���$�$�Q�'���	�	�!�V���M�M� � ��%� �0�������A���1�v�
rc�`�|j|�}|j||jz�S)zEWrite to socket with trailing newline, return number of bytes written)r*r(�linesep�rr0s  r�sendlinezSocketSpawn.sendline`s*���$�$�Q�'���y�y��T�\�\�)�*�*rc�&�|j|�y)zWrite to socket, return NoneN)r(r4s  r�writezSocketSpawn.writees
���	�	�!�rc�4�|D]}|j|��y)z+Call self.write() for each item in sequenceN)r7)r�sequencer0s   r�
writelineszSocketSpawn.writelinesis���	�A��J�J�q�M�	rc#�K�|jj�}	|jj|�d��|jj|�y#|jj|�wxYw�w)N)r
�
gettimeout�
settimeout)rr�
saved_timeouts   r�_timeoutzSocketSpawn._timeoutnsV�������.�.�0�
�	2��K�K�"�"�7�+���K�K�"�"�=�1��D�K�K�"�"�=�1�s�A9�A�A9�A6�6A9c� �|dk(r|j}	|j|�5|jj|�}|dk(rd|_td��|cddd�S#1swYyxYw#tj$rt
d��wxYw)a�
        Read from the file descriptor and return the result as a string.

        The read_nonblocking method of :class:`SpawnBase` assumes that a call
        to os.read will not block (timeout parameter is ignored). This is not
        the case for POSIX file-like objects such as sockets and serial ports.

        Use :func:`select.select`, timeout is implemented conditionally for
        POSIX systems.

        :param int size: Read at most *size* bytes.
        :param int timeout: Wait timeout seconds for file descriptor to be
            ready to read. When -1 (default), use self.timeout. When 0, poll.
        :return: String containing the bytes read
        rrTz
Socket closedNzTimeout exceeded.)rr?r
�recv�flag_eofrr)r�sizerr0s    r�read_nonblockingzSocketSpawn.read_nonblockingws��� �b�=��l�l�G�	/����w�'�
��K�K�$�$�T�*����8�$(�D�M��o�.�.��
�
�
���~�~�	/��-�.�.�	/�s(�A.�4A"�	A.�"A+�'A.�+A.�.B
)N�i�NNN�strictF)rr)�__name__�
__module__�__qualname__�__doc__r
rr"r%�intr(r5r7r:rr?rD�rrrr sw��4���������!��
�
�!�>
�)����+�S�+�
��
�2��2�/r)rJr
�
contextlibr�
exceptionsrr�	spawnbaser�__all__rrLrr�<module>rQs-���,�%�$� ��/��q/�)�q/r

Zerion Mini Shell 1.0