%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/_dumbwin32proc.cpython-312.pyc

�

Ϫ�f(1��R�dZddlZddlZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZmZddlmZddlmZmZmZddlmZej0�Zde_d	�ZGd
�dej8�Zd�Zd
�Zeeee�Gd�dej@e��Z!y)z<
Windows Process Management, used with reactor.spawnProcess
�N)�implementer)�_pollingfile�error)�BaseProcess)�	IConsumer�IProcessTransport�	IProducer)�quoteArguments�c�V�t|�tjj�y�N)�print�sys�stdout�flush)�msgs �A/usr/lib/python3/dist-packages/twisted/internet/_dumbwin32proc.py�debugr$s��	�#�J��J�J����c��eZdZd�Zd�Zy)�_Reaperc��||_yr
)�proc)�selfrs  r�__init__z_Reaper.__init__*s	����	rc�$�tj|jjd�tjk7rytj|jj�}|j�|jj|�y�Nr)	�
win32event�WaitForSingleObjectr�hProcess�
WAIT_OBJECT_0�win32process�GetExitCodeProcess�
deactivate�processEnded)r�exitCodes  r�	checkWorkz_Reaper.checkWork-sh���*�*�4�9�9�+=�+=�q�A��'�'�
(���2�2�4�9�9�3E�3E�F�������	�	���x�(�rN)�__name__�
__module__�__qualname__rr'�rrrr)s���	rrc���t|�5}|jd�dk(r+|jd�jd�}|cddd�S	ddd�y#1swYyxYw)a 
    Look for a #! line, and return the value following the #! if one exists, or
    None if this file is not a script.

    I don't know if there are any conventions for quoting in Windows shebang
    lines, so this doesn't support any; therefore, you may not pass any
    arguments to scripts invoked as filters.  That's probably wrong, so if
    somebody knows more about the cultural expectations on Windows, please feel
    free to fix.

    This shebang line support was added in support of the CGI tests;
    appropriately enough, I determined that shebang lines are culturally
    accepted in the Windows world through this page::

        http://www.cgi101.com/learn/connect/winxp.html

    @param filename: str representing a filename

    @return: a str representing another filename.
    �z#!i�
N)�open�read�readline�strip)�filename�f�exes   r�_findShebangr69s[��*
�h���1��6�6�!�9����*�*�T�"�(�(��.�C��������s�6A�Ac�&�|jddk(S)z�
    Determine if a pywintypes.error is telling us that the given process is
    'not a valid win32 application', i.e. not a PE format executable.

    @param pywinerr: a pywintypes.error instance raised by CreateProcess

    @return: a boolean
    r�)�args)�pywinerrs r�_invalidWin32Appr;Ts���=�=���s�"�"rc��eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdefd�Zy)�Processa�
    A process that integrates with the Twisted event loop.

    If your subprocess is a python program, you need to:

     - Run python.exe with the '-u' command line option - this turns on
       unbuffered I/O. Buffering stdout/err/in can cause problems, see e.g.
       http://support.microsoft.com/default.aspx?scid=kb;EN-US;q1903

     - If you don't want Windows messing with data passed over
       stdin/out/err, set the pipes to be in binary mode::

        import os, sys, mscvrt
        msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
        msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
        msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)

    rc�
�������tjj�|�tj�|�t	j
�}d|_tj|d�\�_	}tj|d�\�_
}	tj|d�\}
�_tj�jtjdd�tj��|�_|	�_|
�_tj&�_t+j,�}t+j.|�j|ddt0j2�}t5j6�j�|�_	t+j.|�j|ddt0j2�}t5j6�j�|�_
t+j.|�j|ddt0j2�}t5j6�j�|�_t8j:j=���j?|xsi��jA�D�
�cic].\}
}t9jB|
�t9jB|���0c}}
�|D�cgc]}t9jB|���}}tE|���rt9jB��n���rt9jB��n��������fd�}	|�t5j6|	�t5j6|�t5j6|
�tjT�j�fd��jV��_,tjT�j�fd	��jZ��_.tj^�j�j`��_1�jX�j\�jbfD]}�je|���jfji���jetk���ycc}}
wcc}w#tFjH$r�}tK|�stM|��tO��}|�tMd�z��tQ|�}|jSd��tE|���}|�	|�nB#tFjH$r,}tK|�rtM|�d|�d���tM|��d}~wwxYwYd}~��d}~wwxYw)
z-
        Create a new child process.
        rrNc���tj}tj��ddd|����	\�_�_�_}y�Nr)�win32con�CREATE_NO_WINDOWr"�
CreateProcessr �hThread�pid)�flags�dwTid�StartupInfo�cmdline�command�env�pathrs  ������r�doCreatez"Process.__init__.<locals>.doCreate�s@����-�-�E�;G�;U�;U���$��a���T�;�<�8�D�M�4�<���5rzD%r is neither a Windows executable, nor a script with a shebang linez has an invalid shebang line: z is not a valid executablec�<���jjd|�Sr@��proto�childDataReceived��datars �r�<lambda>z"Process.__init__.<locals>.<lambda>��������5�5�a��>�rc�<���jjd|�S�Nr-rOrRs �rrTz"Process.__init__.<locals>.<lambda>�rUr)6r�
_PollingTimerrr�
win32security�SECURITY_ATTRIBUTES�bInheritHandle�	win32pipe�
CreatePipe�hStdoutR�hStderrR�hStdinW�SetNamedPipeHandleState�PIPE_NOWAITr"�STARTUPINFO�
hStdOutput�	hStdError�	hStdInput�STARTF_USESTDHANDLES�dwFlags�win32api�GetCurrentProcess�DuplicateHandlerA�DUPLICATE_SAME_ACCESS�	win32file�CloseHandle�os�environ�copy�update�items�fsdecoder
�
pywintypesrr;�OSErrorr6�list�insert�_PollableReadPipe�outConnectionLostr�errConnectionLost�stderr�_PollableWritePipe�inConnectionLost�stdin�_addPollableResourcerP�makeConnectionr)r�reactor�protocolrJr9�environmentrL�sAttrs�hStdoutW�hStderrW�hStdinR�
currentPid�tmp�key�value�xrM�pwte�sheb�origcmd�pwte2�pipewatcherrHrIrKs`  `  `               @@@rrzProcess.__init__|sJ���	�"�"�+�+�D�'�:����T�8�,��2�2�4�� !���#,�"6�"6�v�q�"A���
�x�"+�"6�"6�v�q�"A���
�x� )� 4� 4�V�Q� ?������)�)��L�L�)�/�/��t�	
�
#�.�.�0��!)��� (��� '���*�?�?����/�/�1�
��&�&���
�
�z�1�a��9W�9W�
��	���d�m�m�,���
��&�&���
�
�z�1�a��9W�9W�
��	���d�m�m�,���
��&�&�����j�!�Q��8V�8V�
��	���d�l�l�+�����j�j�o�o����
�
�;�$�"�%�FI�i�i�k�R�
��U�r�{�{�3�����U�!3�3�R��)-�-�1����A��-��-� ��&��+2�"�+�+�g�&�w��$(�r�{�{�4� �d��	�	� 	-��J�D	���h�'����h�'����g�&�#�4�4��M�M�>��"�"�
���#�4�4��M�M�>��"�"�
���"�4�4��L�L�$�/�/�
��
� �;�;����T�Z�Z�?�	3�K��%�%�k�2�	3�	
�
�
�!�!�$�'��!�!�'�$�-�0��aS��.��"���	-�#�D�)��d�m�#�$�G�,���<�!�;�=D�E���
 ��:�D��K�K��7�+�,�T�2�G�%�G�"�G�
-� �
��%�+�+�-�+�E�2�")�BI�4�!Q�#��&�e�n�,��-��#��-	-�sI�3Q-�=Q3�#Q8�8T>�AT9�)S1�0T9�1T0�'T+�+T0�0T9�9T>c��|j�tj��|dvr!tj|j
d�yy)N)�INT�TERM�KILLr)rEr�ProcessExitedAlreadyr"�TerminateProcessr )r�signalIDs  r�
signalProcesszProcess.signalProcesss=���8�8���,�,�.�.��.�.��)�)�$�-�-��;�/rc�`�|dk(rtj|�Stj|�Sr)r�ProcessDone�ProcessTerminated)r�statuss  r�
_getReasonzProcess._getReason
s+���Q�;��$�$�V�,�,��&�&�v�.�.rc�:�|jj|�y)zQ
        Write data to the process' stdin.

        @type data: C{bytes}
        N)r�write)rrSs  rr�z
Process.writes��	
�
�
����rc�:�|jj|�y)z[
        Write data to the process' stdin.

        @type seq: C{list} of C{bytes}
        N)r�
writeSequence)r�seqs  rr�zProcess.writeSequences��	
�
�
� � ��%rc�Z�|dk(r|jj|�yt|��)a;
        Similar to L{ITransport.write} but also allows the file descriptor in
        the child process which will receive the bytes to be specified.

        This implementation is limited to writing to the child's standard input.

        @param fd: The file descriptor to which to write.  Only stdin (C{0}) is
            supported.
        @type fd: C{int}

        @param data: The bytes to write.
        @type data: C{bytes}

        @return: L{None}

        @raise KeyError: If C{fd} is anything other than the stdin file
            descriptor (C{0}).
        rN)rr��KeyError)r�fdrSs   r�writeToChildzProcess.writeToChilds'��&��7��J�J���T�"��2�,�rc��|dk(r|j�y|dk(r|j�y|dk(r|j�ytd��)Nrrr-z4Only standard-IO file descriptors available on win32)�
closeStdin�closeStdout�closeStderr�NotImplementedError)rr�s  r�closeChildFDzProcess.closeChildFD7sI��
��7��O�O��
�1�W�����
�1�W�����%�F��
rc�8�|jj�y)zClose the process' stdin.N)r�close�rs rr�zProcess.closeStdinCs���
�
���rc�8�|jj�yr
)r|r�r�s rr�zProcess.closeStderrG��������rc�8�|jj�yr
)rr�r�s rr�zProcess.closeStdoutJr�rc�d�|j�|j�|j�y)z8
        Close the process' stdout, in and err.
        N)r�r�r�r�s r�loseConnectionzProcess.loseConnectionMs&��	
�����������rc�Z�|jjd�|j�yr@�rP�childConnectionLost�connectionLostNotifyr�s rrzzProcess.outConnectionLostU� ���
�
�&�&�q�)��!�!�#rc�Z�|jjd�|j�yrWr�r�s rr{zProcess.errConnectionLostYr�rc�Z�|jjd�|j�yrr�r�s rr~zProcess.inConnectionLost]r�rc�N�|xjdz
c_|j�y)zS
        Will be called 3 times, by stdout/err threads and process handle.
        rN)�closedNotifies�maybeCallProcessEndedr�s rr�zProcess.connectionLostNotifyas!��	
���q� ���"�"�$rc��|jdk(ro|jrbtj|j�tj|j
�d|_d|_t
j|�yyy)N�)r��lostProcessrmrnr rDrr�r�s rr�zProcess.maybeCallProcessEndedhs`�����!�#��(8�(8��!�!�$�-�-�0��!�!�$�,�,�/� �D�M��D�L��-�-�d�3�)9�#rc�<�|jj||�yr
)r�registerProducer)r�producer�	streamings   rr�zProcess.registerProducerqs���
�
�#�#�H�i�8rc�8�|jj�yr
)r�unregisterProducerr�s rr�zProcess.unregisterProducerts���
�
�%�%�'rc�$�|j�yr
)�_pauser�s r�pauseProducingzProcess.pauseProducingxs�����
rc�$�|j�yr
)�_unpauser�s r�resumeProducingzProcess.resumeProducing{s���
�
�rc�$�|j�yr
)r�r�s r�
stopProducingzProcess.stopProducing~s�����rc��td��)NzUnimplemented: Process.getHost�r�r�s r�getHostzProcess.getHost����!�"B�C�Crc��td��)NzUnimplemented: Process.getPeerr�r�s r�getPeerzProcess.getPeer�r�r�returnc�P�d|jj�d|j�d�S)z@
        Return a string representation of the process.
        �<z pid=�>)�	__class__r(rEr�s r�__repr__zProcess.__repr__�s(���4�>�>�*�*�+�5����
�!�<�<rN)r(r)r*�__doc__r�rr�r�r�r�r�r�r�r�r�r�rzr{r~r�r�r�r�r�r�r�r�r��strr�r+rrr=r=es����&�N�F1�P<�/�
�&��0
�����$�$�$�%�4�9�(����D�D�=�#�=rr=)"r�ror�zope.interfacerrurirArrmr\r"rY�twisted.internetrr�twisted.internet._baseprocessr�twisted.internet.interfacesrrr	�twisted.python.win32r
rZ�PIPE_ATTRS_INHERITABLEr[r�_PollableResourcerr6r;rXr=r+rr�<module>r�s���
�

�
�&���������0�5�O�O�/�;��:�:�<��()��%��

�l�,�,�
� �6#�"
�
�	�9�5�g=�l�(�(�+�g=�6�g=r

Zerion Mini Shell 1.0