%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__/pty_spawn.cpython-312.pyc

�

��e�����ddlZddlZddlZddlZddlZddlZddlZddlmZddl	Z	ddl
mZddlm
Z
mZmZddlmZddlmZmZmZmZed��Zej0dd	k\ZGd
�de�Zd�Zy)
�N)�contextmanager)�use_native_pty_fork�)�ExceptionPexpect�EOF�TIMEOUT)�	SpawnBase)�which�split_command_line�select_ignore_interrupts�poll_ignore_interruptsc#�pK�	d��y#tj$r}t|j��d}~wwxYw�w)z;Turn ptyprocess errors into our own ExceptionPexpect errorsN)�
ptyprocess�PtyProcessErrorr�args)�es �3/usr/lib/python3/dist-packages/pexpect/pty_spawn.py�_wrap_ptyprocess_errrs2����(�
���%�%�(�����'�'��(�s�6�	�6�3�.�3�6�c�N��eZdZdZeZgdddddddddddddf�fd�	Zd	�Zgddfd
�Zd�Zd(d�Z	d
�Z
d)d�Zd�Zd�Z
d*�fd�	Zd�Zd�Zd�Zd+d�Zd�Zd�Zd�Zd�Zed��Zej2d��Zd�Zd,d�Zd�Zd�Zd �Zd!�Zd"�Z e!d#�ddfd$�Z"d%�Z#d&�Z$	d-d'�Z%�xZ&S).�spawnzjThis is the main class interface for Pexpect. Use this class to start
    and control child applications. �i�NFT�strictc����tt|�||||||
��tj|_tj
|_tj|_d|_||_||_	|
|_
|	|_tjj�jd�|_|�d|_d|_d|_||_y|j)||||�||_y)a�This is the constructor. The command parameter may be a string that
        includes a command and any arguments to the command. For example::

            child = pexpect.spawn('/usr/bin/ftp')
            child = pexpect.spawn('/usr/bin/ssh user@example.com')
            child = pexpect.spawn('ls -latr /tmp')

        You may also construct it with a list of arguments like so::

            child = pexpect.spawn('/usr/bin/ftp', [])
            child = pexpect.spawn('/usr/bin/ssh', ['user@example.com'])
            child = pexpect.spawn('ls', ['-latr', '/tmp'])

        After this the child application will be created and will be ready to
        talk to. For normal use, see expect() and send() and sendline().

        Remember that Pexpect does NOT interpret shell meta characters such as
        redirect, pipe, or wild cards (``>``, ``|``, or ``*``). This is a
        common mistake.  If you want to run a command and pipe it through
        another command then you must also start a shell. For example::

            child = pexpect.spawn('/bin/bash -c "ls -l | grep LOG > logs.txt"')
            child.expect(pexpect.EOF)

        The second form of spawn (where you pass a list of arguments) is useful
        in situations where you wish to spawn a command and pass it its own
        argument list. This can make syntax more clear. For example, the
        following is equivalent to the previous example::

            shell_cmd = 'ls -l | grep LOG > logs.txt'
            child = pexpect.spawn('/bin/bash', ['-c', shell_cmd])
            child.expect(pexpect.EOF)

        The maxread attribute sets the read buffer size. This is maximum number
        of bytes that Pexpect will try to read from a TTY at one time. Setting
        the maxread size to 1 will turn off buffering. Setting the maxread
        value higher may help performance in cases where large amounts of
        output are read back from the child. This feature is useful in
        conjunction with searchwindowsize.

        When the keyword argument *searchwindowsize* is None (default), the
        full buffer is searched at each iteration of receiving incoming data.
        The default number of bytes scanned at each iteration is very large
        and may be reduced to collaterally reduce search cost.  After
        :meth:`~.expect` returns, the full buffer attribute remains up to
        size *maxread* irrespective of *searchwindowsize* value.

        When the keyword argument ``timeout`` is specified as a number,
        (default: *30*), then :class:`TIMEOUT` will be raised after the value
        specified has elapsed, in seconds, for any of the :meth:`~.expect`
        family of method calls.  When None, TIMEOUT will not be raised, and
        :meth:`~.expect` may block indefinitely until match.


        The logfile member turns on or off logging. All input and output will
        be copied to the given file object. Set logfile to None to stop
        logging. This is the default. Set logfile to sys.stdout to echo
        everything to standard output. The logfile is flushed after each write.

        Example log input and output to a file::

            child = pexpect.spawn('some_command')
            fout = open('mylog.txt','wb')
            child.logfile = fout

        Example log to stdout::

            # In Python 2:
            child = pexpect.spawn('some_command')
            child.logfile = sys.stdout

            # In Python 3, we'll use the ``encoding`` argument to decode data
            # from the subprocess and handle it as unicode:
            child = pexpect.spawn('some_command', encoding='utf-8')
            child.logfile = sys.stdout

        The logfile_read and logfile_send members can be used to separately log
        the input from the child and output sent to the child. Sometimes you
        don't want to see everything you write to the child. You only want to
        log what the child sends back. For example::

            child = pexpect.spawn('some_command')
            child.logfile_read = sys.stdout

        You will need to pass an encoding to spawn in the above code if you are
        using Python 3.

        To separately log output sent to the child use logfile_send::

            child.logfile_send = fout

        If ``ignore_sighup`` is True, the child process will ignore SIGHUP
        signals. The default is False from Pexpect 4.0, meaning that SIGHUP
        will be handled normally by the child.

        The delaybeforesend helps overcome a weird behavior that many users
        were experiencing. The typical problem was that a user would expect() a
        "Password:" prompt and then immediately call sendline() to send the
        password. The user would then see that their password was echoed back
        to them. Passwords don't normally echo. The problem is caused by the
        fact that most applications print out the "Password" prompt and then
        turn off stdin echo, but if you send your password before the
        application turned off echo, then you get your password echoed.
        Normally this wouldn't be a problem when interacting with a human at a
        real keyboard. If you introduce a slight delay just before writing then
        this seems to clear up the problem. This was such a common problem for
        many users that I decided that the default pexpect behavior should be
        to sleep just before writing to the child application. 1/20th of a
        second (50 ms) seems to be enough to clear up the problem. You can set
        delaybeforesend to None to return to the old behavior.

        Note that spawn is clever about finding commands on your path.
        It uses the same logic that "which" uses to find executables.

        If you wish to get the exit status of the child you must call the
        close() method. The exit or signal status of the child will be stored
        in self.exitstatus or self.signalstatus. If the child exited normally
        then exitstatus will store the exit return code and signalstatus will
        be None. If the child was terminated abnormally with a signal then
        signalstatus will store the signal value and exitstatus will be None::

            child = pexpect.spawn('some_command')
            child.close()
            print(child.exitstatus, child.signalstatus)

        If you need more detail you can also read the self.status member which
        stores the status returned by os.waitpid. You can interpret this using
        os.WIFEXITED/os.WEXITSTATUS or os.WIFSIGNALED/os.TERMSIG.

        The echo attribute may be set to False to disable echoing of input.
        As a pseudo-terminal, all input echoed by the "keyboard" (send()
        or sendline()) will be repeated to output.  For many cases, it is
        not desirable to have echo enabled, and it may be later disabled
        using setecho(False) followed by waitnoecho().  However, for some
        platforms such as Solaris, this is not possible, and should be
        disabled immediately on spawn.

        If preexec_fn is given, it will be called in the child process before
        launching the given command. This is useful to e.g. reset inherited
        signal handlers.

        The dimensions attribute specifies the size of the pseudo-terminal as
        seen by the subprocess, and is specified as a two-entry tuple (rows,
        columns). If this is unspecified, the defaults in ptyprocess will apply.

        The use_poll attribute enables using select.poll() over select.select()
        for socket handling. This is handy if your system could have > 1024 fds
        )�timeout�maxread�searchwindowsize�logfile�encoding�codec_errors�d�irixNz<pexpect factory incomplete>)�superr�__init__�pty�STDIN_FILENO�
STDOUT_FILENO�
STDERR_FILENO�str_last_chars�cwd�env�echo�
ignore_sighup�sys�platform�lower�
startswith�_spawn__irix_hack�commandr�name�_spawn�use_poll)�selfr3rrrrrr*r+r-r,�
preexec_fnrr �
dimensionsr6�	__class__s                �rr$zspawn.__init__$s����r	�e�T�#�G�W�Wg�,3�h�Ua�	$�	c��,�,��� �.�.��� �.�.���!�����������	�*����<�<�-�-�/�:�:�6�B����?��D�L��D�I�6�D�I�!��
�
�K�K���z�:�>� ��
�c��g}|jt|��|jdt|j�z�|jd|j���|jd|j
�d|j|j
d���|jd|j
�d|jr|j|j
dnd���|jd|j���|jd	|j���|jd
t|j�z�|jdt|j�z�t|d�r'|jd
t|j�z�|jdt|j�z�|jdt|j�z�|jdt|j �z�|jdt|j"�z�|jdt|j$�z�|jdt|j&�z�|jdt|j(�z�|jdt|j*�z�|jdt|j,�z�|jdt|j.�z�|jdt|j0�z�|jdt|j2�z�|jdt|j4�z�|jdt|j6�z�dj9|�S)zVThis returns a human-readable string that represents the state of
        the object. z	command: zargs: z
buffer (last z	 chars): Nz
before (last �zafter: zmatch: z
match_index: zexitstatus: �ptyprocz
flag_eof: zpid: z
child_fd: zclosed: z	timeout: zdelimiter: z	logfile: zlogfile_read: zlogfile_send: z	maxread: zignorecase: zsearchwindowsize: zdelaybeforesend: zdelayafterclose: zdelayafterterminate: �
)�append�repr�strr3rr)�buffer�before�after�match�match_index�
exitstatus�hasattr�flag_eof�pid�child_fd�closedr�	delimiterr�logfile_read�logfile_sendr�
ignorecaser�delaybeforesend�delayafterclose�delayafterterminate�join�r7�ss  r�__str__z
spawn.__str__�s���
��	����d���	����s�4�<�<�0�0�1�	���t�y�y�*�+�	����1D�1D�T�[�[�RV�Re�Re�Qe�Qf�Eg�h�i�	����1D�1D�ko�kv�kv�T�[�[�RV�Re�Re�Qe�Qf�Eg�|~�E~��	A�	����
�
�,�-�	����
�
�,�-�	����3�t�'7�'7�#8�8�9�	����#�d�o�o�"6�6�7��4��#�
�H�H�\�C��
�
�$6�6�7�	����3�t�x�x�=�(�)�	�����D�M�M� 2�2�3�	����c�$�+�+�.�.�/�	����s�4�<�<�0�0�1�	�����T�^�^�!4�4�5�	����s�4�<�<�0�0�1�	���!�C��(9�(9�$:�:�;�	���!�C��(9�(9�$:�:�;�	����s�4�<�<�0�0�1�	����#�d�o�o�"6�6�7�	���%��D�,A�,A�(B�B�C�	���$�s�4�+?�+?�'@�@�A�	���$�s�4�+?�+?�'@�@�A�	���(�3�t�/G�/G�+H�H�I��y�y��|�r;c���t|td��rtd��t|tg��std��|gk(r%t	|�|_|j
d|_n-|dd|_|j
jd|�||_t|j|j��}|�tdd|jzz��||_|j|j
d<dd	j|j
�zd
z|_|j�Jd��|j�Jd��|j�d
�}|jr
�fd�}||d<|�||d<|j�J|j
D�cgc]/}t|t �r|n|j#|j���1c}|_|j$|j
f|j|j&d�|��|_|j(j|_|j(j*|_d|_d|_ycc}w)aThis starts the given command in a child process. This does all the
        fork/exec type of stuff for a pty. This is called by __init__. If args
        is empty then command will be parsed (split on spaces) and args will be
        set to parsed arguments. rz�Command is an int type. If this is a file descriptor then maybe you want to use fdpexpect.fdspawn which takes an existing file descriptor instead of a command string.z#The argument, args, must be a list.N)r+z%The command was not found or was not zexecutable: %s.�<� �>zThe pid member must be None.z$The command member must not be None.)r,r8c�~��tjtjtj�����yy)z7Set SIGHUP to be ignored, then call the real preexec_fnN)�signal�SIGHUP�SIG_IGN)r8s�r�preexec_wrapperz%spawn._spawn.<locals>.preexec_wrapper s)����
�
�f�m�m�V�^�^�<��)��L�*r;r8r9)r+r*F)�
isinstance�typer�	TypeErrorrrr3�insertr
r+rUr4rKr,r-r�bytes�encode�	_spawnptyr*r>�fdrL�
terminatedrM)	r7r3rr8r9�command_with_path�kwargsra�as	   `     rr5zspawn._spawn�s��� �g�t�A�w�'�"�$C�D�
D�
�$��R��)��A�B�B��2�:�*�7�3�D�I��9�9�Q�<�D�L��Q��D�I��I�I���Q��(�"�D�L�!�$�,�,�D�H�H�=���$�"�#J�%����4�$5�6�
6�(����|�|��	�	�!���#�(�(�4�9�9�-�-��3��	��x�x��?�!?�?���|�|�'�O�)O�O�'��)�)�:�>�����
!�
$3�F�<� ��!�#-�F�<� ��=�=�$�#'�)�)�-��)��E�2��������8O�O�-�D�I�&�t�~�~�d�i�i�=�T�X�X�)-���=�5;�=����<�<�#�#���������
� �������-s�	4Ic�B�tjj|fi|��S)z1Spawn a pty and return an instance of PtyProcess.)r�
PtyProcessr)r7rrls   rrhzspawn._spawnpty9s���$�$�*�*�4�:�6�:�:r;c���|j�t�5|jj|��ddd�|j	�d|_d|_y#1swY�(xYw)a?This closes the connection with the child application. Note that
        calling close() more than once is valid. This emulates standard Python
        behavior with files. Set force to True if you want to make sure that
        the child is terminated (SIGKILL is sent if the child ignores SIGHUP
        and SIGINT). )�forceN���T)�flushrr>�close�isaliverLrM�r7rqs  rrtzspawn.close=sX��	
�
�
��
!�
#�	,�
�L�L���U��+�	,�	
������
����
	,�	,�s�A�A(c�@�tj|j�S)a^This returns True if the file descriptor is open and connected to a
        tty(-like) device, else False.

        On SVR4-style platforms implementing streams, such as SunOS and HP-UX,
        the child pty may not appear as a terminal device.  This means
        methods such as setecho(), setwinsize(), getwinsize() may raise an
        IOError. )�os�isattyrL�r7s rryzspawn.isattyMs���y�y����'�'r;c���|dk(r|j}|�tj�|z}	|j�sy|dkr|�y|�tj�z
}tjd��H)aThis waits until the terminal ECHO flag is set False. This returns
        True if the echo mode is off. This returns False if the ECHO flag was
        not set False before the timeout. This can be used to detect when the
        child is waiting for a password. Usually a child application will turn
        off echo mode when it is waiting for the user to enter a password. For
        example, instead of expecting the "password:" prompt you can wait for
        the child to set ECHO off::

            p = pexpect.spawn('ssh user@example.com')
            p.waitnoecho()
            p.sendline(mypassword)

        If timeout==-1 then this method will use the value in self.timeout.
        If timeout==None then this method to block until ECHO flag is False.
        rrTrFg�������?)r�time�getecho�sleep)r7r�end_times   r�
waitnoechozspawn.waitnoechoXsn��"�b�=��l�l�G����y�y�{�W�,�H���<�<�>����{�w�2���"�"�T�Y�Y�[�0���J�J�s�O�r;c�6�|jj�S)aThis returns the terminal echo mode. This returns True if echo is
        on or False if echo is off. Child applications that are expecting you
        to enter a password often set ECHO False. See waitnoecho().

        Not supported on platforms where ``isatty()`` returns False.  )r>r}rzs rr}z
spawn.getechovs���|�|�#�#�%�%r;c�8�|jj|�S)aZThis sets the terminal echo mode on or off. Note that anything the
        child sent before the echo will be lost, so you should be sure that
        your input buffer is empty before you call setecho(). For example, the
        following will work as expected::

            p = pexpect.spawn('cat') # Echo is on by default.
            p.sendline('1234') # We expect see this twice from the child...
            p.expect(['1234']) # ... once from the tty echo...
            p.expect(['1234']) # ... and again from cat itself.
            p.setecho(False) # Turn off tty echo
            p.sendline('abcd') # We will set this only once (echoed by cat).
            p.sendline('wxyz') # We will set this only once (echoed by cat)
            p.expect(['abcd'])
            p.expect(['wxyz'])

        The following WILL NOT WORK because the lines sent before the setecho
        will be lost::

            p = pexpect.spawn('cat')
            p.sendline('1234')
            p.setecho(False) # Turn off tty echo
            p.sendline('abcd') # We will set this only once (echoed by cat).
            p.sendline('wxyz') # We will set this only once (echoed by cat)
            p.expect(['1234'])
            p.expect(['1234'])
            p.expect(['abcd'])
            p.expect(['wxyz'])


        Not supported on platforms where ``isatty()`` returns False.
        )r>�setecho)r7�states  rr�z
spawn.setecho~s��@�|�|�#�#�E�*�*r;c�����jrtd���jr�fd�}n�fd�}|d�rf	tt��|�}t|�|krB|d�r:	|tt��|t|�z
�z
}t|�|kr	|d�r�:|S|dk(r�j}�j�s-|d�rtt��|�Sd�_
t
d���jr	|�|dkrd}|dk7r||�rtt��|�S�j�sd�_
t
d	��td
��#t$r�j��wxYw#t$r�j�|cYSwxYw)azThis reads at most size characters from the child application. It
        includes a timeout. If the read does not complete within the timeout
        period then a TIMEOUT exception is raised. If the end of file is read
        then an EOF exception will be raised.  If a logfile is specified, a
        copy is written to that log.

        If timeout is None then the read may block indefinitely.
        If timeout is -1 then the self.timeout value is used. If timeout is 0
        then the child is polled and if there is no data immediately ready
        then this will raise a TIMEOUT exception.

        The timeout refers only to the amount of time to read at least one
        character. This is not affected by the 'size' parameter, so if you call
        read_nonblocking(size=100, timeout=30) and only one character is
        available right away then one character will be returned immediately.
        It will not wait for 30 seconds for another 99 characters to come in.

        On the other hand, if there are bytes available to read immediately,
        all those bytes will be read (up to the buffer size). So, if the
        buffer size is 1 megabyte and there is 1 megabyte of data available
        to read, the buffer will be filled, regardless of timeout.

        This is a wrapper around os.read(). It uses select.select() or
        select.poll() to implement the timeout. zI/O operation on closed file.c�2��t�jg|�S�N)r
rL�rr7s �r�selectz&spawn.read_nonblocking.<locals>.select�s���-�t�}�}�o�w�G�Gr;c�<��t�jggg|�dS)Nr)rrLr�s �rr�z&spawn.read_nonblocking.<locals>.select�s ���/������R��Q�RS�T�Tr;rrrTz&End Of File (EOF). Braindead platform.�z&End of File (EOF). Very slow platform.zTimeout exceeded.)
rM�
ValueErrorr6r#r�read_nonblockingrru�lenrrJr2r)r7�sizerr��incomingr:s`    �rr�zspawn.read_nonblocking�s����4�;�;��<�=�=��=�=�
H�
U��!�9�
� ���>�t�D��
�h�-�$�&�6�!�9�$���e�T� C�D�3�x�=�DX� Y�Y�H��h�-�$�&�6�!�9��O��b�=��l�l�G��|�|�~��a�y��U�D�:�4�@�@� �D�M��>�?�?�
�
�
�
�"�w��{���

�q�L�f�W�o����6�t�<�<��|�|�~�!�D�M��>�?�?��-�.�.��c�
������
���$��L�L�N�#�O�	$�s�E�$"E-�E*�-F�
Fc�&�|j|�y)zHThis is similar to send() except that there is no return value.
        N)�sendrVs  r�writezspawn.writes��	
�	�	�!�r;c�4�|D]}|j|��y)z�This calls write() for each element in the sequence. The sequence
        can be any iterable object producing strings, typically a list of
        strings. This does not add line separators. There is no return value.
        N)r�)r7�sequencerWs   r�
writelineszspawn.writeliness���	�A��J�J�q�M�	r;c��|j�tj|j�|j|�}|j	|d�|j
j
|d��}tj|j|�S)a�Sends string ``s`` to the child process, returning the number of
        bytes written. If a logfile is specified, a copy is written to that
        log.

        The default terminal input mode is canonical processing unless set
        otherwise by the child process. This allows backspace and other line
        processing to be performed prior to transmitting to the receiving
        program. As this is buffered, there is a limited size of such buffer.

        On Linux systems, this is 4096 (defined by N_TTY_BUF_SIZE). All
        other systems honor the POSIX.1 definition PC_MAX_CANON -- 1024
        on OSX, 256 on OpenSolaris, and 1920 on FreeBSD.

        This value may be discovered using fpathconf(3)::

            >>> from os import fpathconf
            >>> print(fpathconf(0, 'PC_MAX_CANON'))
            256

        On such a system, only 256 bytes may be received per line. Any
        subsequent bytes received will be discarded. BEL (``''``) is then
        sent to output if IMAXBEL (termios.h) is set by the tty driver.
        This is usually enabled by default.  Linux does not honor this as
        an option -- it behaves as though it is always set on.

        Canonical input processing may be disabled altogether by executing
        a shell, then stty(1), before executing the final program::

            >>> bash = pexpect.spawn('/bin/bash', echo=False)
            >>> bash.sendline('stty -icanon')
            >>> bash.sendline('base64')
            >>> bash.sendline('x' * 5000)
        r�F)�final)
rRr|r~�_coerce_send_string�_log�_encoderrgrxr�rL)r7rW�bs   rr�z
spawn.sendso��F���+��J�J�t�+�+�,��$�$�Q�'���	�	�!�V���M�M� � ��%� �0���x�x��
�
�q�)�)r;c�`�|j|�}|j||jz�S)aWraps send(), sending string ``s`` to child process, with
        ``os.linesep`` automatically appended. Returns number of bytes
        written.  Only a limited number of bytes may be sent for each
        line in the default terminal mode, see docstring of :meth:`send`.
        )r�r��lineseprVs  r�sendlinezspawn.sendline;s,��
�$�$�Q�'���y�y��T�\�\�)�*�*r;c�x�|j�|j|jd�}|j|d�y)z5Write control characters to the appropriate log filesN�replacer�)r�decoder�rVs  r�_log_controlzspawn._log_controlDs.���=�=�$�������	�2�A��	�	�!�V�r;c�d�|jj|�\}}|j|�|S)aHelper method that wraps send() with mnemonic access for sending control
        character to the child (such as Ctrl-C or Ctrl-D).  For example, to send
        Ctrl-G (ASCII 7, bell, '')::

            child.sendcontrol('g')

        See also, sendintr() and sendeof().
        )r>�sendcontrolr�)r7�char�n�bytes    rr�zspawn.sendcontrolJs/���,�,�*�*�4�0���4����$���r;c�`�|jj�\}}|j|�y)a1This sends an EOF to the child. This sends a character which causes
        the pending parent output buffer to be sent to the waiting child
        program without waiting for end-of-line. If it is the first character
        of the line, the read() in the user program returns 0, which signifies
        end-of-file. This means to work as expected a sendeof() has to be
        called at the beginning of a line. This method does not send a newline.
        It is the responsibility of the caller to ensure the eof is sent at the
        beginning of a line. N)r>�sendeofr��r7r�r�s   rr�z
spawn.sendeofWs(���,�,�&�&�(���4����$�r;c�`�|jj�\}}|j|�y)znThis sends a SIGINT to the child. It does not require
        the SIGINT to be the first character on a line. N)r>�sendintrr�r�s   rr�zspawn.sendintrds(���,�,�'�'�)���4����$�r;c�.�|jjSr��r>rJrzs rrJzspawn.flag_eofks���|�|�$�$�$r;c�&�||j_yr�r�)r7�values  rrJzspawn.flag_eofos�� %����r;c��|jS)z@This returns True if the EOF exception was ever raised.
        )rJrzs r�eofz	spawn.eofss���}�}�r;c�&�|j�sy	|jtj�t	j
|j�|j�sy|jtj�t	j
|j�|j�sy|jtj�t	j
|j�|j�sy|rP|jtj�t	j
|j�|j�syyy#t$r4t	j
|j�|j�sYyYywxYw)z�This forces a child process to terminate. It starts nicely with
        SIGHUP and SIGINT. If "force" is True then moves onto SIGKILL. This
        returns True if the child was terminated. This returns False if the
        child could not be terminated. TF)ru�killr^r_r|r~rT�SIGCONT�SIGINT�SIGKILL�OSErrorrvs  r�	terminatezspawn.terminatexs���|�|�~��	��I�I�f�m�m�$��J�J�t�/�/�0��<�<�>���I�I�f�n�n�%��J�J�t�/�/�0��<�<�>���I�I�f�m�m�$��J�J�t�/�/�0��<�<�>����	�	�&�.�.�)��
�
�4�3�3�4��|�|�~�� ����		�

�J�J�t�/�/�0��<�<�>���		�s'�AE�"AE�1AE�AE�8F�Fc���|j}t�5|j�}ddd�|j|_|j|_|j
|_d|_S#1swY�ExYw)a@This waits until the child exits. This is a blocking call. This will
        not read any data from the child, so this will block forever if the
        child has unread output and has terminated. In other words, the child
        may have printed output then called exit(), but, the child is
        technically still alive until its output is read by the parent.

        This method is non-blocking if :meth:`wait` has already been called
        previously or :meth:`isalive` method returns False.  It simply returns
        the previously determined exit status.
        NT)r>r�wait�statusrH�signalstatusrj)r7r>rHs   rr�z
spawn.wait�sj���,�,��
!�
#�	(�!����J�	(��n�n���!�,�,���#�0�0��������	(�	(�s�A,�,A5c���|j}t�5|j�}ddd�s:|j|_|j|_|j
|_d|_|S#1swY�GxYw)aZThis tests if the child process is running or not. This is
        non-blocking. If the child was terminated then this will read the
        exitstatus or signalstatus of the child. This returns True if the child
        process appears to be running or False if not. It can take literally
        SECONDS for Solaris to return the right status. NT)r>rrur�rHr�rj)r7r>�alives   rruz
spawn.isalive�sk���,�,��
!�
#�	&��O�O�%�E�	&��!�.�.�D�K�%�0�0�D�O� '� 4� 4�D��"�D�O���	&�	&�s�A.�.A7c�f�|j�r!tj|j|�yy)z�This sends the given signal to the child application. In keeping
        with UNIX tradition it has a misleading name. It does not necessarily
        kill the child unless you send the right signal. N)rurxr�rK)r7�sigs  rr�z
spawn.kill�s$���<�<�>��G�G�D�H�H�c�"�r;c�6�|jj�S)zmThis returns the terminal window size of the child tty. The return
        value is a tuple of (rows, cols). )r>�
getwinsizerzs rr�zspawn.getwinsize�s���|�|�&�&�(�(r;c�:�|jj||�S)a=This sets the terminal window size of the child tty. This will cause
        a SIGWINCH signal to be sent to the child. This does not change the
        physical window size. It changes the size reported to TTY-aware
        applications like vi or curses -- applications that respond to the
        SIGWINCH signal. )r>�
setwinsize)r7�rows�colss   rr�zspawn.setwinsize�s���|�|�&�&�t�T�2�2r;�c�4�|j|j�|jj�|j	�|_t
j|j�}t
j|j�|�tr|jd�}	|j|||�t
j|jtj|�y#t
j|jtj|�wxYw)a�This gives control of the child process to the interactive user (the
        human at the keyboard). Keystrokes are sent to the child process, and
        the stdout and stderr output of the child process is printed. This
        simply echos the child stdout and child stderr to the real stdout and
        it echos the real stdin to the child stdin. When the user types the
        escape_character this method will return None. The escape_character
        will not be transmitted.  The default for escape_character is
        entered as ``Ctrl - ]``, the very same as BSD telnet. To prevent
        escaping, escape_character may be set to None.

        If a logfile is specified, then the data sent and received from the
        child process in interact mode is duplicated to the given log.

        You may pass in optional input and output filter functions. These
        functions should take bytes array and return bytes array too. Even
        with ``encoding='utf-8'`` support, meth:`interact` will always pass
        input_filter and output_filter bytes. You may need to wrap your
        function to decode and encode back to UTF-8.

        The output_filter will be passed all the output from the child process.
        The input_filter will be passed all the keyboard input from the user.
        The input_filter is run BEFORE the check for the escape_character.

        Note that if you change the window size of the parent the SIGWINCH
        signal will not be passed through to the child. If you want the child
        window size to change when the parent's window size changes then do
        something like the following example::

            import pexpect, struct, fcntl, termios, signal, sys
            def sigwinch_passthrough (sig, data):
                s = struct.pack("HHHH", 0, 0, 0, 0)
                a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(),
                    termios.TIOCGWINSZ , s))
                if not p.closed:
                    p.setwinsize(a[0],a[1])

            # Note this 'p' is global and used in sigwinch_passthrough.
            p = pexpect.spawn('/bin/bash')
            signal.signal(signal.SIGWINCH, sigwinch_passthrough)
            p.interact()
        Nzlatin-1)�write_to_stdoutrC�stdoutrs�buffer_type�_buffer�tty�	tcgetattrr&�setraw�PY3rg�_spawn__interact_copy�	tcsetattr�	TCSAFLUSH)r7�escape_character�input_filter�
output_filter�modes     r�interactzspawn.interact�s���\	
���T�[�[�)��������'�'�)����}�}�T�.�.�/���
�
�4�$�$�%��'�C�/�6�6�y�A��	B�� � �!1�<��O��M�M�$�+�+�S�]�]�D�A��C�M�M�$�+�+�S�]�]�D�A�s�#C&�&1Dc��|dk7rD|j�r3tj||�}||d}|dk7r|j�r�1yyyy)�/This is used by the interact() method.
        r;N)rurxr�)r7ri�datar�s    r�__interact_writenzspawn.__interact_writensE���c�k�d�l�l�n�����T�"�A����8�D��c�k�d�l�l�n�k�n�kr;c�.�tj|d�S)r�i�)rx�read)r7ris  r�__interact_readzspawn.__interact_read%s���w�w�r�4� � r;c��|j��r�|jr"t|j|jg�}n't|j|jggg�\}}}|j|vr^	|j
|j�}|dk(ry|r||�}|j|d�tj|j|�|j|vr�|j
|j�}|r||�}d}	|�|j|�}	|	dk7r6|d|	}|r|j|d�|j!|j|�y|j|d�|j!|j|�|j�r���yy#t$r+}|jdtjk(rYd}~y�d}~wwxYw)r�rNr;r�rrr�)rur6r
rLr&r�_spawn__interact_readr�r�errno�EIOr�rxr�r'�rfind�_spawn__interact_writen)
r7r�r�r��r�wrr��err�is
          r�__interact_copyzspawn.__interact_copy+s����l�l�n��}�}�*�D�M�M�4�;L�;L�+M�N��2��]�]�D�$5�$5�6��B����1�a��}�}��!���/�/��
�
�>�D��3�;�� �(��.�D��	�	�$��'�����+�+�T�2�� � �A�%��+�+�D�,=�,=�>���'��-�D���#�/��
�
�#3�4�A���7����8�D���	�	�$��/��*�*�4�=�=�$�?���	�	�$��'��&�&�t�}�}�d�;�I�l�l�n�n�����x�x��{�e�i�i�/����	�s�6F�	G�! G�G�G)T)rr)rrr)r=)F)NNN)'�__name__�
__module__�__qualname__�__doc__rr$rXr5rhrtryr�r}r�r�r�r�r�r�r�r�r�r��propertyrJ�setterr�r�r�rur�r�r��chrr�r�r�r��
__classcell__)r:s@rrrs���(�.��%'��T�"&��$�D�$�4�D��X�$��	j!�X�@$&�$�4�G�R;�� 	(��<&� +�D^/�@��**�X+��� � ��%��%��_�_�&��&��
&�P�0�&#�)�
3�),�B���T�8B�t�!�GK�+<r;rc�<�|jdd�t|i|��S)z-Deprecated: pass encoding to spawn() instead.rzutf-8)�
setdefaultr)rrls  r�spawnur�Ys"��
���j�'�*��$�!�&�!�!r;)rxr.r|r%r�r�r^�
contextlibrr�ptyprocess.ptyprocessr�
exceptionsrrr�	spawnbaser	�utilsr
rrr
r�version_infor�rr��r;r�<module>r�su��	�
��
�
��
�%��5�6�6� ����(��(������a���y<�I�y<�x"r;

Zerion Mini Shell 1.0