
    Vh                    $   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZ  e       Z eej                          G d d	             Z eej$                  ej&                  ej(                  ej*                         G d
 d             Zy)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
    )annotations)implementer)
interfacesprocess)	IProtocolIReactorFDSet)Logger)Failurec                      e Zd Zy)PipeAddressN)__name__
__module____qualname__     L/home/dcms/DCMS/lib/python3.12/site-packages/twisted/internet/_posixstdio.pyr   r      s    r   r   c                      e Zd ZdZdZdZdZ	 	 	 d	 	 	 	 	 	 	 ddZd Zd Z	d Z
d Zd Zd	 Zdd
ZddZd ZddZddZd Zd Zd Zd Zd Zd Zd Zd Zd Zy)
StandardIONFc                    |ddl m} || _        t        j                  || d|      | _        t        j                  || d|      | _        | j                  j                          | j                  j                  |        y )Nr   )reactorwriteread)
twisted.internetr   protocolr   ProcessWriter_writerProcessReader_readerstartReadingmakeConnection)selfprotostdinstdoutr   s        r   __init__zStandardIO.__init__*   se     ?0#(,,WdGVL,,WdFEJ!!#$$T*r   c                R    | j                   | j                   j                          y y N)r   loseConnectionr!   s    r   loseWriteConnectionzStandardIO.loseWriteConnection=   !    <<#LL'') $r   c                T    | j                   | j                   j                  |       y y r'   )r   r   r!   datas     r   r   zStandardIO.writeA   s#    <<#LLt$ $r   c                T    | j                   | j                   j                  |       y y r'   )r   writeSequencer-   s     r   r0   zStandardIO.writeSequenceE   s#    <<#LL&&t, $r   c                    d| _         | j                  | j                  j                          | j                  | j                  j	                          y y )NT)disconnectingr   r(   r   stopReadingr)   s    r   r(   zStandardIO.loseConnectionI   sC    !<<#LL'')<<#LL$$& $r   c                    t               S r'   r   r)   s    r   getPeerzStandardIO.getPeerR   
    }r   c                    t               S r'   r5   r)   s    r   getHostzStandardIO.getHostU   r7   r   c                :    | j                   j                  |       y r'   )r   dataReceived)r!   fdr.   s      r   childDataReceivedzStandardIO.childDataReceivedY   s    ""4(r   c                n    | j                   ry |dk(  r| j                  |       y | j                  |       y )Nr   )disconnected_readConnectionLost_writeConnectionLost)r!   r<   reasons      r   childConnectionLostzStandardIO.childConnectionLost\   s1    <$$V,%%f-r   c                v   d| _         | j                  }| j                  }| j                  }d x| _        | _        d | _        ||j                   s|j	                  |       ||j                   s|j	                  |       t
        j                  d      5  |j	                  |       d d d        y # 1 sw Y   y xY w)NTz#while calling stdio connectionLost:)r?   r   r   r   connectionLost_logfailuresHandled)r!   rB   r   r   r   s        r   rE   zStandardIO.connectionLostd   s      ,,,,==&**t|w';';""6*w';';""6*!!"GH 	,##F+	, 	, 	,s   B//B8c                X   d | _         | j                  r| j                  |       y t        j                  | j
                  d       }|rWt        j                  d      5 }|j                          d d d        j                  r| j                  |j                         y y y # 1 sw Y   3xY w)Nz(while calling stdio writeConnectionLost:)r   r2   rE   r   IHalfCloseableProtocolr   rF   rG   writeConnectionLostfailedfailure)r!   rB   pwcls       r   rA   zStandardIO._writeConnectionLostw   s    '--dmmTB%%: (%%'( zz##CKK0  ( (s   B  B)c                >   d | _         t        j                  | j                  d       }|rWt        j                  d      5 }|j                          d d d        j                  r| j                  |j                         y y | j                  |       y # 1 sw Y   DxY w)Nz'while calling stdio readConnectionLost:)
r   r   rI   r   rF   rG   readConnectionLostrK   rE   rL   )r!   rB   rM   rcls       r   r@   zStandardIO._readConnectionLost   s    --dmmTB%%&OP 'TW$$&'zz##CKK0  '' 's   BBc                v    | j                   |j                          y | j                   j                  ||       y r'   )r   stopProducingregisterProducer)r!   producer	streamings      r   rT   zStandardIO.registerProducer   s,    <<""$LL))(I>r   c                R    | j                   | j                   j                          y y r'   )r   unregisterProducerr)   s    r   rX   zStandardIO.unregisterProducer   s!    <<#LL++- $r   c                $    | j                          y r'   )r(   r)   s    r   rS   zStandardIO.stopProducing   s    r   c                R    | j                   | j                   j                          y y r'   )r   pauseProducingr)   s    r   r[   zStandardIO.pauseProducing   r+   r   c                R    | j                   | j                   j                          y y r'   )r   resumeProducingr)   s    r   r]   zStandardIO.resumeProducing   s!    <<#LL((* $r   c                $    | j                          y)z3Compatibility only, don't use. Call pauseProducing.N)r[   r)   s    r   r3   zStandardIO.stopReading   s    r   c                $    | j                          y)z4Compatibility only, don't use. Call resumeProducing.N)r]   r)   s    r   r   zStandardIO.startReading   s    r   c                    t               r'   NotImplementedErrorr!   rB   s     r   rP   zStandardIO.readConnectionLost       !##r   c                    t               r'   ra   rc   s     r   rJ   zStandardIO.writeConnectionLost   rd   r   )r      N)r"   r   r#   intr$   rg   r   zIReactorFDSet | None)r<   strr.   bytesreturnNone)r<   rh   rB   r
   rj   rk   )rB   r
   rj   rk   )r   r   r   r   r   r?   r2   r%   r*   r   r0   r(   r6   r9   r=   rC   rE   rA   r@   rT   rX   rS   r[   r]   r3   r   rP   rJ   r   r   r   r   r      s     GGLM
 (,++ + 	+
 &+&*%-').,&1	(?.
*+$$r   r   N)__doc__
__future__r   zope.interfacer   r   r   r   twisted.internet.interfacesr   r   twisted.loggerr	   twisted.python.failurer
   rF   IAddressr   
ITransport	IProducer	IConsumerIHalfCloseableDescriptorr   r   r   r   <module>rw      s   	 # & 0 @ ! *x Z  !	 	 "	 ''	R$ R$R$r   