Ϫf dZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z m Z ddlmZmZmZGddeZGd d e j(ZGd d eZd ZddZedk(reyy)zC Asynchronous local terminal input handling @author: Jp Calderone N)ServerProtocol)ColoredManhole)deferprotocolreactorstdio)failurelogreflectc eZdZy)UnexpectedOutputErrorN)__name__ __module__ __qualname__5/usr/lib/python3/dist-packages/twisted/conch/stdio.pyr r srr c6eZdZdZdZdZdZdZdZdZ y) TerminalProcessProtocolcD||_tj|_yN)protorDeferred onConnection)selfrs r__init__z TerminalProcessProtocol.__init__s !NN,rc~|jj||jjdd|_yr)rmakeConnectionrcallback)rs rconnectionMadez&TerminalProcessProtocol.connectionMades0 !!$' ""4( rc:|jj|y)zj Write to the terminal. @param data: Data to write. @type data: L{bytes} N) transportwriterdatas rr#zTerminalProcessProtocol.write$s T"rc:|jj|y)zs Receive data from the terminal. @param data: Data received. @type data: L{bytes} N)r dataReceivedr$s r outReceivedz#TerminalProcessProtocol.outReceived-s %rc|jj|j?|jjt j t |d|_yy)zt Report an error. @param data: Data to include in L{Failure}. @type data: L{bytes} N)r"loseConnectionrconnectionLostr Failurer r$s r errReceivedz#TerminalProcessProtocol.errReceived6sK %%' :: ! JJ % %goo6KD6Q&R SDJ "rcT|j|jj|yyr)rchildConnectionLost)rchildFDs rr/z+TerminalProcessProtocol.childConnectionLostBs# :: ! JJ * *7 3 "rcb|j#|jj|d|_yyr)rr+rreasons r processEndedz$TerminalProcessProtocol.processEndedFs* :: ! JJ % %f -DJ "rN) rrrrr r#r(r-r/r4rrrrrs%-! #& 4rrceZdZdZdZy)ConsoleManholezK A manhole protocol specifically for use with L{stdio.StandardIO}. c,tjy)z When the connection is lost, there is nothing more to do. Stop the reactor so that the process can exit. N)rstopr2s rr+zConsoleManhole.connectionLostQs  rN)rrr__doc__r+rrrr6r6Ls rr6ctjj}tj|}t j | tjt|tjtj|tj|tj|dy#tj|tj|tj|dwxYw)Ns c )sys __stdin__filenotermios tcgetattrttysetrawr StandardIOrrrun tcsetattrTCSANOWosr#)klassfd oldSettingss rrunWithProtocolrJYs    B##B'KJJrN# ./ "goo{; \" "goo{; \"s 2B88=C5ctjtdd|tjdd}|rt j |d}nt}t|y)Nz child.logwr) r startLoggingopenr;argvr namedClassr6rJ)rPrGs rmainrResOT+s+, |xx| ""47+Er__main__r)r9rFr;r>r@twisted.conch.insults.insultsrtwisted.conch.manholertwisted.internetrrrrtwisted.pythonr r r Exceptionr ProcessProtocolrr6rJrRrrrrrZss    80<<00 I /h66/d ^  #  zFr