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

�

��e���dZddlZddlZddlZddlZddlZddlZddlZ	ddlm	Z	m
Z
ddlm
Z
mZddlmZddlmZGd�d	e
�Zy#e$rddl	m	Z	m
Z
Y�/wxYw)
zJProvides an interface like pexpect.spawn interface using subprocess.Popen
�N)�Queue�Empty�)�	SpawnBase�PY3)�EOF)�string_typesc�b��eZdZ			d�fd�	ZdZd�Zd�Zd�Zd�Zd�Z	d
d�Z
d	�Zd
�Zd�Z
�xZS)�
PopenSpawnc	���tt|�||||||	��|�%tjjd�|_n$|jtj�|_tdtjtjtj||
|��}tjdk(rOtj�}|xjtj zc_||d<tj"|d<t%|t&�r;tjdk7r(t)j*|tj,dk(�	�}tj.|fi|��|_|j0j2|_d
|_|j�|_t9�|_t=j>|j@��|_!d|jB_"|jBjG�y)
N)�timeout�maxread�searchwindowsize�logfile�encoding�codec_errors�asciir)�bufsize�stdin�stderr�stdout�cwd�
preexec_fn�env�win32�startupinfo�
creationflags�posix)rF)�targetT)$�superr�__init__�os�linesep�encode�crlf�string_type�dict�
subprocess�PIPE�STDOUT�sys�platform�STARTUPINFO�dwFlags�STARTF_USESHOWWINDOW�CREATE_NEW_PROCESS_GROUP�
isinstancer	�shlex�split�name�Popen�proc�pid�closed�_bufr�_read_queue�	threading�Thread�_read_incoming�_read_thread�daemon�start)�self�cmdr
rrrrrrrr�kwargsr�	__class__s             ��5/usr/lib/python3/dist-packages/pexpect/popen_spawn.pyr!zPopenSpawn.__init__s~���	�j�$�(��'�!1�7�!��	)�	>����
�
�)�)�7�3�D�I��(�(�"�*�*�5�D�I��a�z���'�.�.�z����*�#�?���<�<�7�"�$�0�0�2�K����:�#B�#B�B��$/�F�=�!�&0�&I�&I�F�?�#��c�<�(�S�\�\�W�-D��+�+�c����G�);�<�C��$�$�S�3�F�3��	��9�9�=�=�������$�$�&��	� �7���%�,�,�D�4G�4G�H���#'���� ������!�Fc�f�|j}|jr#|r||d|_|d|Sd|_td��|dk(r
|j}n|�d}tj
�}tj
�|z
|kr�|r~t
|�|krp	|jj�}|�d|_nK||jj|d��z
}tj
�|z
|kr|rt
|�|kr�p|d|||dc}|_|j|d�|S#t$rY�/wxYw)NTzEnd Of File (EOF).���g��.AF��final�read)
r9�_read_reached_eof�flag_eofrr
�time�lenr:�
get_nowait�_decoder�decoder�_log)rA�sizer
�buf�t0�incoming�rs       rE�read_nonblockingzPopenSpawn.read_nonblockingAs7���i�i���!�!�����J��	��5�D�z�!� $��
��.�/�/��b�=��l�l�G�
�_��G�
�Y�Y�[���y�y�{�R��7�*�t��C��4��	
C��+�+�6�6�8���#�-1�D�*���t�}�}�+�+�H�E�+�B�B���y�y�{�R��7�*�t��C��4���5�D�z�3�t�u�:���4�9��	�	�!�V������
��
�s�D$�$	D0�/D0c�B�|jjj�}	d}	tj|d�}|s|jjd�y|jj|��S#t
$r}|j
|d�Yd}~�Zd}~wwxYw)z6Run in a thread to move output from a pipe to a queue.rFirKN)	r6r�filenor"rK�OSErrorrSr:�put)rAr[rU�es    rEr=zPopenSpawn._read_incomingds������!�!�(�(�*����C�
%��g�g�f�d�+���� � �$�$�T�*����� � ��%����
%��	�	�!�V�$�$��
%�s�A9�9	B�B�Bc�&�|j|�y)zHThis is similar to send() except that there is no return value.
        N��send)rA�ss  rE�writezPopenSpawn.writeus��	
�	�	�!�rFc�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.
        Nr`)rA�sequencerbs   rE�
writelineszPopenSpawn.writelineszs���	�A��I�I�a�L�	rFc�8�|j|�}|j|d�|jj|d��}tr%|j
jj|�S|j
jj|�t|�S)zZSend data to the subprocess' stdin.

        Returns the number of bytes written.
        raFrI)	�_coerce_send_stringrS�_encoderr$rr6rrcrO)rArb�bs   rErazPopenSpawn.send�sx��

�$�$�Q�'���	�	�!�V���M�M� � ��%� �0����9�9�?�?�(�(��+�+�
�I�I�O�O�!�!�!�$��q�6�MrFc�`�|j|�}||j|j�zS)z�Wraps send(), sending string ``s`` to child process, with os.linesep
        automatically appended. Returns number of bytes written. )rar#)rArb�ns   rE�sendlinezPopenSpawn.sendline�s)��
�I�I�a�L���4�9�9�T�\�\�*�*�*rFc��|jj�}|dk\r||_d|_nd|_||_d|_|S)zKWait for the subprocess to finish.

        Returns the exit code.
        rNT)r6�wait�
exitstatus�signalstatus�
terminated)rA�statuss  rErozPopenSpawn.wait�sG��
�����!���Q�;�$�D�O� $�D��"�D�O�!'��D������
rFc�j�tjdk(rv|tjtjfvrtj}nC|tj
tjfvrtj}ntj}tj|jj|�y)z}Sends a Unix signal to the subprocess.

        Use constants from the :mod:`signal` module to specify which signal.
        rN)r+r,�signal�SIGINT�CTRL_C_EVENT�SIGBREAK�CTRL_BREAK_EVENT�SIGTERMr"�killr6r7)rA�sigs  rEr{zPopenSpawn.kill�ss��
�<�<�7�"��v�}�}�f�&9�&9�:�:��)�)������&�*A�*A�B�B��-�-���n�n��
����	�	�
�
�s�#rFc�L�|jjj�y)z+Closes the stdin pipe from the writing end.N)r6r�close)rAs rE�sendeofzPopenSpawn.sendeof�s���	�	�����rF)	�i�NNNNN�strictN)�)�__name__�
__module__�__qualname__r!rLrYr=rcrfrarmror{r�
__classcell__)rDs@rErrsH���GK�<@�37�("�T��!�F&�"�
��"+�
�
$� rFr)�__doc__r"r;r(r+rNrur2�queuerr�ImportError�	spawnbaserr�
exceptionsr�utilsr	r�rFrE�<module>r�sW���	���
��
��#�"�&���h ��h ���#�"�"�#�s�A�
A�A

Zerion Mini Shell 1.0