
    \d                         d Z ddlmZ ddlmZmZmZ ddlmZm	Z	  eej
                   G d d                      Z eej        ej        ej        ej                   G d d                      Zd	S )
zStandard input/out/err support.

Future Plans::

    support for stderr, perhaps
    Rewrite to use the reactor instead of an ad-hoc mechanism for connecting
        protocols to transport.

Maintainer: James Y Knight
    )implementer)error
interfacesprocess)failurelogc                       e Zd ZdS )PipeAddressN)__name__
__module____qualname__     <lib/python3.11/site-packages/twisted/internet/_posixstdio.pyr
   r
      s        Dr   r
   c                       e Zd ZdZdZdZdZddZd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )
StandardIONFr      c                     |ddl m} || _        t          j        || d|          | _        t          j        || d|          | _        | j                                         | j        	                    |            d S )Nr   )reactorwriteread)
twisted.internetr   protocolr   ProcessWriter_writerProcessReader_readerstartReadingmakeConnection)selfprotostdinstdoutr   s        r   __init__zStandardIO.__init__&   s    ?000000,WdGVLL,WdFEJJ!!###$$T*****r   c                 J    | j         | j                                          d S d S N)r   loseConnectionr    s    r   loseWriteConnectionzStandardIO.loseWriteConnection3   ,    <#L''))))) $#r   c                 L    | j         | j                             |           d S d S r&   )r   r   r    datas     r   r   zStandardIO.write7   s.    <#Lt$$$$$ $#r   c                 L    | j         | j                             |           d S d S r&   )r   writeSequencer,   s     r   r/   zStandardIO.writeSequence;   s.    <#L&&t,,,,, $#r   c                     d| _         | j        | j                                         | j        | j                                         d S d S NT)disconnectingr   r'   r   stopReadingr(   s    r   r'   zStandardIO.loseConnection?   sP    !<#L'')))<#L$$&&&&& $#r   c                     t                      S r&   r
   r(   s    r   getPeerzStandardIO.getPeerH       }}r   c                     t                      S r&   r5   r(   s    r   getHostzStandardIO.getHostK   r7   r   c                 :    | j                             |           d S r&   )r   dataReceived)r    fdr-   s      r   childDataReceivedzStandardIO.childDataReceivedO   s    ""4(((((r   c                     | j         rd S |j        j        t          j        k    r4|dk    r|                     |           d S |                     |           d S |                     |           d S )Nr   )disconnectedvalue	__class__r   ConnectionDone_readConnectionLost_writeConnectionLostconnectionLost)r    r<   reasons      r   childConnectionLostzStandardIO.childConnectionLostR   s|     	F<!U%999V||((00000))&11111'''''r   c                 T   d| _         | j        }| j        }| j        }d x| _        | _        d | _        ||j         s|                    |           ||j         s|                    |           	 |                    |           d S # t
          $ r t          j                     Y d S w xY wr1   )r?   r   r   r   rE   BaseExceptionr   err)r    rF   r   r   r   s        r   rE   zStandardIO.connectionLost_   s      ,,=&**t|w';""6***w';""6***	##F+++++ 	 	 	GIIIIII	s   /B B'&B'c                 J   d | _         | j        r|                     |           d S t          j        | j        d           }|ra	 |                                 d S # t          $ r= t          j	                     |                     t          j                               Y d S w xY wd S r&   )r   r2   rE   r   IHalfCloseableProtocolr   writeConnectionLostrI   r   rJ   r   Failurer    rF   ps      r   rD   zStandardIO._writeConnectionLostt   s     	'''F-dmTBB 	77%%'''''  7 7 7			##GO$5$56666667	7 	7s   A AB B c                 8   d | _         t          j        | j        d           }|ra	 |                                 d S # t
          $ r= t          j                     |                     t          j
                               Y d S w xY w|                     |           d S r&   )r   r   rL   r   readConnectionLostrI   r   rJ   rE   r   rN   rO   s      r   rC   zStandardIO._readConnectionLost   s    -dmTBB 	(7$$&&&&&  7 7 7			##GO$5$56666667 '''''s   ; ABBc                 v    | j         |                                 d S | j                             ||           d S r&   )r   stopProducingregisterProducer)r    producer	streamings      r   rU   zStandardIO.registerProducer   s@    <""$$$$$L))(I>>>>>r   c                 J    | j         | j                                          d S d S r&   )r   unregisterProducerr(   s    r   rY   zStandardIO.unregisterProducer   s,    <#L++----- $#r   c                 .    |                                   d S r&   )r'   r(   s    r   rT   zStandardIO.stopProducing   s    r   c                 J    | j         | j                                          d S d S r&   )r   pauseProducingr(   s    r   r\   zStandardIO.pauseProducing   r*   r   c                 J    | j         | j                                          d S d S r&   )r   resumeProducingr(   s    r   r^   zStandardIO.resumeProducing   s,    <#L((***** $#r   c                 .    |                                   dS )z3Compatibility only, don't use. Call pauseProducing.N)r\   r(   s    r   r3   zStandardIO.stopReading   s    r   c                 .    |                                   dS )z4Compatibility only, don't use. Call resumeProducing.N)r^   r(   s    r   r   zStandardIO.startReading   s    r   c                     t                      r&   NotImplementedErrorr    rF   s     r   rR   zStandardIO.readConnectionLost       !###r   c                     t                      r&   rb   rd   s     r   rM   zStandardIO.writeConnectionLost   re   r   )r   r   N)r   r   r   r   r   r?   r2   r$   r)   r   r/   r'   r6   r9   r=   rG   rE   rD   rC   rU   rY   rT   r\   r^   r3   r   rR   rM   r   r   r   r   r      sj        GGLM+ + + +* * *% % %- - -' ' '    ) ) )( ( (  *7 7 7
( 
( 
(? ? ?. . .
  * * *+ + +    $ $ $$ $ $ $ $r   r   N)__doc__zope.interfacer   r   r   r   r   twisted.pythonr   r   IAddressr
   
ITransport	IProducer	IConsumerIHalfCloseableDescriptorr   r   r   r   <module>ro      s
  	 	 ' & & & & & 7 7 7 7 7 7 7 7 7 7 ' ' ' ' ' ' ' ' Z !!	 	 	 	 	 	 	 "!	 '	 T$ T$ T$ T$ T$ T$ T$ T$ T$ T$r   