Ñò §ÚêLc @ s¶ d Z d d k l Z d d k Z d d k Z d d d g Z d Z d Z d Z d Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z e e d „ Z e e d „ Z d S( s Pseudo terminal utilities.iÿÿÿÿ( t selectNt openptyt forkt spawni i i c C sO y t i ƒ SWn t t f j o n Xt ƒ \ } } t | ƒ } | | f S( sd openpty() -> (master_fd, slave_fd) Open a pty master/slave pair, using os.openpty() if possible.( t osR t AttributeErrort OSErrort _open_terminalt slave_open( t master_fdt slave_namet slave_fd( ( s /usr/lib64/python2.6/pty.pyR s c C s_ y t i ƒ \ } } Wn t t f j o n( Xt i | ƒ } t i | ƒ | | f St ƒ S( s› master_open() -> (master_fd, slave_name) Open a pty master and return the fd, and the filename of the slave end. Deprecated, use openpty() instead.( R R R R t ttynamet closeR ( R R R ( ( s /usr/lib64/python2.6/pty.pyt master_open! s c C sú y d d k } Wn t j o nR Xy" | i t i d d ƒ \ } } Wn! t j o } t i | ‚ n X| | f Sxq d D]i } x` d D]X } d | | } y t i | t i ƒ } Wn t i j o qŠ n X| d | | f SWq} Wt i d ‚ d S( sl Open pty master and return (master_fd, tty_name). SGI and generic BSD version, for when openpty() fails.iÿÿÿÿNi¶ i t pqrstuvwxyzPQRSTt 0123456789abcdefs /dev/ptys /dev/ttys out of pty devices( t sgit ImportErrort _getptyR t O_RDWRt IOErrort errort open( R t tty_nameR t msgt xt yt pty_namet fd( ( s /usr/lib64/python2.6/pty.pyR 1 s( " c C s„ t i | t i ƒ } y d d k l } l } Wn t j o | SXy$ | | | d ƒ | | | d ƒ Wn t j o n X| S( s© slave_open(tty_name) -> slave_fd Open the pty slave and acquire the controlling terminal, returning opened filedescriptor. Deprecated, use openpty() instead.iÿÿÿÿ( t ioctlt I_PUSHt ptemt ldterm( R R R t fcntlR R R R ( R t resultR R ( ( s /usr/lib64/python2.6/pty.pyR H s c C sD y t i ƒ \ } } Wn t t f j o nA X| t j o( y t i ƒ Wqg t j o qg Xn | | f St ƒ \ } } t i ƒ } | t j o” t i ƒ t i | ƒ t i | t ƒ t i | t ƒ t i | t ƒ | t j o t i | ƒ n t i t i t ƒ t i ƒ } t i | ƒ n t i | ƒ | | f S( sd fork() -> (pid, master_fd) Fork and make the child a session leader with a controlling terminal.( R t forkptyR R t CHILDt setsidR R R t dup2t STDIN_FILENOt STDOUT_FILENOt STDERR_FILENOR R R ( t pidR R R t tmp_fd( ( s /usr/lib64/python2.6/pty.pyR Z s0 c C s5 x. | d j o t i | | ƒ } | | } q Wd S( s# Write all the data to a descriptor.t N( R t write( R t datat n( ( s /usr/lib64/python2.6/pty.pyt _writen‚ s c C s t i | d ƒ S( s Default read function.i ( R t read( R ( ( s /usr/lib64/python2.6/pty.pyt _readˆ s c C s‚ x{ t | t g g g ƒ \ } } } | | j o | | ƒ } t i t | ƒ n t | j o | t ƒ } t | | ƒ q q d S( s Parent copy loop. Copies pty master -> standard output (master_read) standard input -> pty master (stdin_read)N( R R( R R. R) R1 ( R t master_readt stdin_readt rfdst wfdst xfdsR/ ( ( s /usr/lib64/python2.6/pty.pyt _copyŒ s c C s t | ƒ t d ƒ j o | f } n t ƒ \ } } | t j o t i | d | Œ n y&