
    Yf                       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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
    )annotations)implementer)
interfacesprocess)	IProtocolIReactorFDSet)Logger)Failurec                      e Zd ZdS )PipeAddressN)__name__
__module____qualname__     N/var/www/html/env/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*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dS ).
StandardIONFr      protor   stdinintstdoutreactorIReactorFDSet | Nonec                    |ddl m} || _        t          j        || d|          | _        t          j        || d|          | _        | j                                         | j        	                    |            d S )Nr   )r   writeread)
twisted.internetr   protocolr   ProcessWriter_writerProcessReader_readerstartReadingmakeConnection)selfr   r   r   r   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.loseWriteConnection=   ,    <#L''))))) $#r   c                L    | j         | j                             |           d S d S r*   )r"   r   r'   datas     r   r   zStandardIO.writeA   s.    <#Lt$$$$$ $#r   c                L    | j         | j                             |           d S d S r*   )r"   writeSequencer0   s     r   r3   zStandardIO.writeSequenceE   s.    <#L&&t,,,,, $#r   c                    d| _         | j        | j                                         | j        | j                                         d S d S )NT)disconnectingr"   r+   r$   stopReadingr,   s    r   r+   zStandardIO.loseConnectionI   sP    !<#L'')))<#L$$&&&&& $#r   c                    t                      S r*   r   r,   s    r   getPeerzStandardIO.getPeerR       }}r   c                    t                      S r*   r8   r,   s    r   getHostzStandardIO.getHostU   r:   r   fdstrr1   bytesreturnNonec                :    | j                             |           d S r*   )r    dataReceived)r'   r=   r1   s      r   childDataReceivedzStandardIO.childDataReceivedY   s    ""4(((((r   reasonr
   c                |    | j         rd S |dk    r|                     |           d S |                     |           d S )Nr   )disconnected_readConnectionLost_writeConnectionLost)r'   r=   rE   s      r   childConnectionLostzStandardIO.childConnectionLost\   sO     	F<<$$V,,,,,%%f-----r   c                p   d| _         | j        }| j        }| j        }d x| _        | _        d | _        ||j         s|                    |           ||j         s|                    |           t
                              d          5  |                    |           d d d            d S # 1 swxY w Y   d S )NTz#while calling stdio connectionLost:)rG   r$   r"   r    connectionLost_logfailuresHandled)r'   rE   r$   r"   r    s        r   rL   zStandardIO.connectionLostd   s     ,,=&**t|w';""6***w';""6***!!"GHH 	, 	,##F+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   B++B/2B/c                ^   d | _         | j        r|                     |           d S t          j        | j        d           }|rit                              d          5 }|                                 d d d            n# 1 swxY w Y   |j	        r|                     |j
                   d S d S d S )Nz(while calling stdio writeConnectionLost:)r"   r5   rL   r   IHalfCloseableProtocolr    rM   rN   writeConnectionLostfailedfailure)r'   rE   pwcls       r   rI   zStandardIO._writeConnectionLostw   s    	'''F-dmTBB 	1%%:  (%%'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( z 1##CK00000	1 	1
1 1s   A==BBc                L   d | _         t          j        | j        d           }|rkt                              d          5 }|                                 d d d            n# 1 swxY w Y   |j        r|                     |j	                   d S d S |                     |           d S )Nz'while calling stdio readConnectionLost:)
r$   r   rP   r    rM   rN   readConnectionLostrR   rL   rS   )r'   rE   rT   rcls       r   rH   zStandardIO._readConnectionLost   s    -dmTBB 	(%%&OPP 'TW$$&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' 'z 1##CK000001 1 '''''s   AA#&A#c                v    | j         |                                 d S | j                             ||           d S r*   )r"   stopProducingregisterProducer)r'   producer	streamings      r   r[   zStandardIO.registerProducer   s@    <""$$$$$L))(I>>>>>r   c                J    | j         | j                                          d S d S r*   )r"   unregisterProducerr,   s    r   r_   zStandardIO.unregisterProducer   s,    <#L++----- $#r   c                .    |                                   d S r*   )r+   r,   s    r   rZ   zStandardIO.stopProducing   s    r   c                J    | j         | j                                          d S d S r*   )r$   pauseProducingr,   s    r   rb   zStandardIO.pauseProducing   r.   r   c                J    | j         | j                                          d S d S r*   )r$   resumeProducingr,   s    r   rd   zStandardIO.resumeProducing   s,    <#L((***** $#r   c                .    |                                   dS )z3Compatibility only, don't use. Call pauseProducing.N)rb   r,   s    r   r6   zStandardIO.stopReading   s    r   c                .    |                                   dS )z4Compatibility only, don't use. Call resumeProducing.N)rd   r,   s    r   r%   zStandardIO.startReading   s    r   c                    t                      r*   NotImplementedErrorr'   rE   s     r   rW   zStandardIO.readConnectionLost       !###r   c                    t                      r*   rh   rj   s     r   rQ   zStandardIO.writeConnectionLost   rk   r   )r   r   N)r   r   r   r   r   r   r   r   )r=   r>   r1   r?   r@   rA   )r=   r>   rE   r
   r@   rA   )rE   r
   r@   rA   )r   r   r   r$   r"   rG   r5   r(   r-   r   r3   r+   r9   r<   rD   rJ   rL   rI   rH   r[   r_   rZ   rb   rd   r6   r%   rW   rQ   r   r   r   r   r      s        GGLM
 (,+ + + + +&* * *% % %- - -' ' '    ) ) ) ). . . ., , ,&1 1 1 1	( 	( 	( 	(? ? ?. . .
  * * *+ + +    $ $ $$ $ $ $ $r   r   N)__doc__
__future__r   zope.interfacer   r   r   r   twisted.internet.interfacesr   r   twisted.loggerr	   twisted.python.failurer
   rM   IAddressr   
ITransport	IProducer	IConsumerIHalfCloseableDescriptorr   r   r   r   <module>rx      sE  	 	 # " " " " " & & & & & & 0 0 0 0 0 0 0 0 @ @ @ @ @ @ @ @ ! ! ! ! ! ! * * * * * *vxx Z !!	 	 	 	 	 	 	 "!	 '	 R$ R$ R$ R$ R$ R$ R$ R$ R$ R$r   