ó
{íKc           @   sœ   d  Z  d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z m	 Z	 d d l
 m Z m Z d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ d S(
   sÚ   Standard 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
iÿÿÿÿN(   t
   implements(   t   processt   errort
   interfaces(   t   logt   failuret   PipeAddressc           B   s   e  Z e e j ƒ RS(    (   t   __name__t
   __module__R    R   t   IAddress(    (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR      s   t
   StandardIOc           B   sù   e  Z e e j e j e j e j ƒ d Z	 d Z
 e Z e Z d  d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! RS(   i    i   c         C   sÑ   d d l  m } | |  _ t j | |  d | ƒ |  _ y |  j j ƒ  WnM t k
 r” } | j t j	 k rŽ t
 d | t j | ƒ j f ƒ ‚ n  ‚  n Xt j | |  d | ƒ |  _ |  j j ƒ  |  j j |  ƒ d  S(   Niÿÿÿÿ(   t   reactort   writes’   This reactor does not support this type of file descriptor (fd %d, mode %d) (for example, epollreactor does not support normal files.  See #4429).t   read(   t   twisted.internetR   t   protocolR   t   ProcessWritert   _writert   startReadingt   IOErrort   errnot   EPERMt   RuntimeErrort   ost   fstatt   st_modet   ProcessReadert   _readert   makeConnection(   t   selft   protot   stdint   stdoutR   t   e(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt   __init__    s    	c         C   s#   |  j  d  k	 r |  j  j ƒ  n  d  S(   N(   R   t   Nonet   loseConnection(   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt   loseWriteConnection:   s    c         C   s&   |  j  d  k	 r" |  j  j | ƒ n  d  S(   N(   R   R#   R   (   R   t   data(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR   >   s    c         C   s&   |  j  d  k	 r" |  j  j | ƒ n  d  S(   N(   R   R#   t   writeSequence(   R   R&   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR'   B   s    c         C   sK   t  |  _ |  j d  k	 r( |  j j ƒ  n  |  j d  k	 rG |  j j ƒ  n  d  S(   N(   t   Truet   disconnectingR   R#   R$   R   t   stopReading(   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR$   F   s
    	c         C   s   t  ƒ  S(   N(   R   (   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt   getPeerO   s    c         C   s   t  ƒ  S(   N(   R   (   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt   getHostR   s    c         C   s   |  j  j | ƒ d  S(   N(   R   t   dataReceived(   R   t   fdR&   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt   childDataReceivedW   s    c         C   s_   |  j  r d  S| j j t j k rN | d k r> |  j | ƒ q[ |  j | ƒ n |  j | ƒ d  S(   NR   (   t   disconnectedt   valuet	   __class__R   t   ConnectionDonet   _readConnectionLostt   _writeConnectionLostt   connectionLost(   R   R.   t   reason(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt   childConnectionLostZ   s    	c         C   s²   t  |  _ |  j } |  j } |  j } d  |  _ |  _ d  |  _ | d  k	 rc | j rc | j | ƒ n  | d  k	 r‰ | j r‰ | j | ƒ n  y | j | ƒ Wn t j ƒ  n Xd  S(   N(	   R(   R0   R   R   R   R#   R6   R   t   err(   R   R7   R   R   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR6   g   s    					c         C   sz   d  |  _ |  j r# |  j | ƒ d  St j |  j d  ƒ } | rv y | j ƒ  Wqv t j	 ƒ  |  j t
 j ƒ  ƒ qv Xn  d  S(   N(   R#   R   R)   R6   R   t   IHalfCloseableProtocolR   t   writeConnectionLostR   R9   R   t   Failure(   R   R7   t   p(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR5   |   s    		
c         C   sm   d  |  _ t j |  j d  ƒ } | r\ y | j ƒ  Wqi t j ƒ  |  j t	 j
 ƒ  ƒ qi Xn |  j | ƒ d  S(   N(   R#   R   R   R:   R   t   readConnectionLostR   R9   R6   R   R<   (   R   R7   R=   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR4   Š   s    	
c         C   s3   |  j  d  k r | j ƒ  n |  j  j | | ƒ d  S(   N(   R   R#   t   stopProducingt   registerProducer(   R   t   producert	   streaming(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR@   —   s    c         C   s#   |  j  d  k	 r |  j  j ƒ  n  d  S(   N(   R   R#   t   unregisterProducer(   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyRC      s    c         C   s   |  j  ƒ  d  S(   N(   R$   (   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR?   ¢   s    c         C   s#   |  j  d  k	 r |  j  j ƒ  n  d  S(   N(   R   R#   t   pauseProducing(   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyRD   ¥   s    c         C   s#   |  j  d  k	 r |  j  j ƒ  n  d  S(   N(   R   R#   t   resumeProducing(   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyRE   ©   s    c         C   s'   t  j d d t d d ƒ|  j ƒ  d S(   s;   Compatibility only, don't use. Same as loseWriteConnection.s=   This function is deprecated, use loseWriteConnection instead.t   categoryt
   stackleveli   N(   t   warningst   warnt   DeprecationWarningR%   (   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt
   closeStdin®   s    c         C   s   |  j  ƒ  d S(   s3   Compatibility only, don't use. Call pauseProducing.N(   RD   (   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR*   ´   s    c         C   s   |  j  ƒ  d S(   s4   Compatibility only, don't use. Call resumeProducing.N(   RE   (   R   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR   ¸   s    N("   R   R   R    R   t
   ITransportt	   IProducert	   IConsumert   IHalfCloseableDescriptorR#   R   R   t   FalseR0   R)   R"   R%   R   R'   R$   R+   R,   R/   R8   R6   R5   R4   R@   RC   R?   RD   RE   RK   R*   R   (    (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyR
      s2   																			(   t   __doc__RH   R   R   t   zope.interfaceR    R   R   R   R   t   twisted.pythonR   R   t   objectR   R
   (    (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_posixstdio.pyt   <module>   s   $