Ë
    ojÕ
  ã                   óê   — d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
mZmZmZ ddlmZmZmZ  G d„ de«      Z G d	„ d
ej(                  «      Z G d„ de«      Zd„ Zdd„Zedk(  r e«        yy)zC
Asynchronous local terminal input handling

@author: Jp Calderone
é    N)ÚServerProtocol)ÚColoredManhole)ÚdeferÚprotocolÚreactorÚstdio)ÚfailureÚlogÚreflectc                   ó   — e Zd Zy)ÚUnexpectedOutputErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    ú5/usr/lib/python3/dist-packages/twisted/conch/stdio.pyr   r      s   „ Ør   r   c                   ó6   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚTerminalProcessProtocolc                 óD   — || _         t        j                  «       | _        y ©N)Úprotor   ÚDeferredÚonConnection)Úselfr   s     r   Ú__init__z TerminalProcessProtocol.__init__   s   € ØˆŒ
Ü!ŸN™NÓ,ˆÕr   c                 ó~   — | j                   j                  | «       | j                  j                  d «       d | _        y r   )r   ÚmakeConnectionr   Úcallback)r   s    r   ÚconnectionMadez&TerminalProcessProtocol.connectionMade   s0   € Ø�
‰
×!Ñ! $Ô'Ø×Ñ×"Ñ" 4Ô(Ø ˆÕr   c                 ó:   — | j                   j                  |«       y)zj
        Write to the terminal.

        @param data: Data to write.
        @type data: L{bytes}
        N)Ú	transportÚwrite©r   Údatas     r   r#   zTerminalProcessProtocol.write$   s   € ð 	�‰×Ñ˜TÕ"r   c                 ó:   — | j                   j                  |«       y)zs
        Receive data from the terminal.

        @param data: Data received.
        @type data: L{bytes}
        N)r   ÚdataReceivedr$   s     r   ÚoutReceivedz#TerminalProcessProtocol.outReceived-   s   € ð 	�
‰
×Ñ Õ%r   c                 óÎ   — | j                   j                  «        | j                  �?| j                  j                  t	        j
                  t        |«      «      «       d| _        yy)zt
        Report an error.

        @param data: Data to include in L{Failure}.
        @type data: L{bytes}
        N)r"   ÚloseConnectionr   ÚconnectionLostr	   ÚFailurer   r$   s     r   ÚerrReceivedz#TerminalProcessProtocol.errReceived6   sK   € ð 	�‰×%Ñ%Ô'Ø�:‰:Ð!Ø�J‰J×%Ñ%¤g§o¡oÔ6KÈDÓ6QÓ&RÔSØˆD�Jð "r   c                 óT   — | j                   �| j                   j                  |«       y y r   )r   ÚchildConnectionLost)r   ÚchildFDs     r   r/   z+TerminalProcessProtocol.childConnectionLostB   s#   € Ø�:‰:Ð!Ø�J‰J×*Ñ*¨7Õ3ð "r   c                 ób   — | j                   �#| j                   j                  |«       d | _         y y r   )r   r+   ©r   Úreasons     r   ÚprocessEndedz$TerminalProcessProtocol.processEndedF   s*   € Ø�:‰:Ð!Ø�J‰J×%Ñ% fÔ-ØˆD�Jð "r   N)
r   r   r   r   r    r#   r(   r-   r/   r4   r   r   r   r   r      s%   „ ò-ò!ò
#ò&ò
ò4ór   r   c                   ó   — e Zd ZdZd„ Zy)ÚConsoleManholezK
    A manhole protocol specifically for use with L{stdio.StandardIO}.
    c                 ó,   — t        j                  «        y)zƒ
        When the connection is lost, there is nothing more to do.  Stop the
        reactor so that the process can exit.
        N)r   Ústopr2   s     r   r+   zConsoleManhole.connectionLostQ   s   € ô
 	�‰�r   N)r   r   r   Ú__doc__r+   r   r   r   r6   r6   L   s   „ ñór   r6   c                 óð  — t         j                  j                  «       }t        j                  |«      }t        j                  |«       	 t        j                  t        | «      «       t        j                  «        t        j                  |t        j                  |«       t        j                  |d«       y # t        j                  |t        j                  |«       t        j                  |d«       w xY w)Ns   c)ÚsysÚ	__stdin__ÚfilenoÚtermiosÚ	tcgetattrÚttyÚsetrawr   Ú
StandardIOr   r   ÚrunÚ	tcsetattrÚTCSANOWÚosr#   )ÚklassÚfdÚoldSettingss      r   ÚrunWithProtocolrJ   Y   sœ   € Ü	�‰×	Ñ	Ó	€BÜ×#Ñ# BÓ'€KÜ‡J�Jˆr„Nð#Ü×Ñœ¨Ó.Ô/Ü�‰Œä×Ñ˜"œgŸo™o¨{Ô;Ü
�‰��\Õ"øô 	×Ñ˜"œgŸo™o¨{Ô;Ü
�‰��\Õ"ús   Á
2B8 Â8=C5c                 óÄ   — t        j                  t        dd«      «       | €t        j                  dd  } | rt        j                  | d   «      }nt        }t        |«       y )Nz	child.logÚwé   r   )	r
   ÚstartLoggingÚopenr;   Úargvr   Ú
namedClassr6   rJ   )rP   rG   s     r   ÚmainrR   e   sO   € Ü×Ñ”T˜+ sÓ+Ô,à€|Ü�x‰x˜˜ˆ|ˆÙÜ×"Ñ" 4¨¡7Ó+‰äˆÜ�EÕr   Ú__main__r   )r9   rF   r;   r>   r@   Útwisted.conch.insults.insultsr   Útwisted.conch.manholer   Útwisted.internetr   r   r   r   Útwisted.pythonr	   r
   r   Ú	Exceptionr   ÚProcessProtocolr   r6   rJ   rR   r   r   r   r   ú<module>rZ      ss   ðñ
ó 
Û 
Û Û 
å 8Ý 0ß <Ó <ß 0Ñ 0ô	˜Iô 	ô/˜h×6Ñ6ô /ôd
�^ô 
ò	#ó	ð ˆzÒÙ…Fð r   