ó
×	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 d l m Z m Z d d l m Z d e f d	     YZ d
 e j f d     YZ d S(   sM   
Windows-specific implementation of the L{twisted.internet.stdio} interface.
iÿÿÿÿN(   t
   implements(   t   IHalfCloseableProtocolt
   ITransportt   IAddress(   t	   IConsumert   IPushProducer(   t   _pollingfilet   main(   t   Failuret   Win32PipeAddressc           B   s   e  Z e e  RS(    (   t   __name__t
   __module__R    R   (    (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR	      s   t
   StandardIOc           B   s±   e  Z e e e e  e Z e 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(   c         C   sê   d d l  m } x- t d d d  D] } t j | t j  q# Wt j j	 |  |  | |  _
 t j t j  } t j t j  } t j | |  j |  j  |  _ t j | |  j  |  _ |  j |  j  |  j |  j  |  j
 j |   d S(   s   
        Start talking to standard IO with the given protocol.

        Also, put it stdin/stdout/stderr into binary mode.
        iÿÿÿÿ(   t   reactori    i   i   N(   t   twisted.internetR   t   ranget   msvcrtt   setmodet   ost   O_BINARYR   t   _PollingTimert   __init__t   protot   win32apit   GetStdHandlet   STD_INPUT_HANDLEt   STD_OUTPUT_HANDLEt   _PollableReadPipet   dataReceivedt   readConnectionLostt   stdint   _PollableWritePipet   writeConnectionLostt   stdoutt   _addPollableResourcet   makeConnection(   t   selfR   R   t   stdfdt   hstdint   hstdout(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR   !   s    	c         C   s   |  j  j |  d  S(   N(   R   R   (   R$   t   data(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR   =   s    c         C   s0   t  j |  j  r" |  j j   n  |  j   d  S(   N(   R   t
   providedByR   R   t   checkConnLost(   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR   @   s    c         C   s0   t  j |  j  r" |  j j   n  |  j   d  S(   N(   R   R)   R   R    R*   (   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR    E   s    i    c         C   sP   |  j  d 7_  |  j  d k rL t |  _ t |  _ |  j j t t j   n  d  S(   Ni   i   (	   t	   connsLostt   Truet   disconnectingt   disconnectedR   t   connectionLostR   R   t   CONNECTION_DONE(   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR*   L   s
    		c         C   s   |  j  j |  d  S(   N(   R!   t   write(   R$   R(   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR1   U   s    c         C   s   |  j  j d j |   d  S(   Nt    (   R!   R1   t   join(   R$   t   seq(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyt   writeSequenceX   s    c         C   s'   t  |  _ |  j j   |  j j   d  S(   N(   R,   R-   R   t   closeR!   (   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyt   loseConnection[   s    	c         C   s   t    S(   N(   R	   (   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyt   getPeer`   s    c         C   s   t    S(   N(   R	   (   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyt   getHostc   s    c         C   s   |  j  j | |  S(   N(   R!   t   registerProducer(   R$   t   producert	   streaming(    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR:   h   s    c         C   s   |  j  j   S(   N(   R!   t   unregisterProducer(   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR=   k   s    c         C   s   |  j  j   d  S(   N(   R   t   stopProducing(   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR>   r   s    c         C   s   |  j  j   d  S(   N(   R   t   pauseProducing(   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR?   w   s    c         C   s   |  j  j   d  S(   N(   R   t   resumeProducing(   R$   (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR@   z   s    (   R
   R   R    R   R   R   t   FalseR-   R.   R   R   R   R    R+   R*   R1   R5   R7   R8   R9   R:   R=   R>   R?   R@   (    (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyR      s*   															(   t   __doc__R   R   R   t   zope.interfaceR    t   twisted.internet.interfacesR   R   R   R   R   R   R   R   t   twisted.python.failureR   t   objectR	   R   R   (    (    (    s@   /usr/lib/python2.7/dist-packages/twisted/internet/_win32stdio.pyt   <module>   s   