ó
àÆ÷Xc           @` sS   d  d l  m Z m Z m Z d  d l Z d  d l Z d „  Z d „  Z d „  Z d S(   i    (   t   absolute_importt   print_functiont   divisionNc         K` sÿ   d } t j d k rŽ t j ƒ  } y | j t j O_ Wn& t k
 r_ | j t j j O_ n Xt	 | d <t
 |  t ƒ rŽ d j |  ƒ }  qŽ n  d } d | k rÂ t t j ƒ } | j ƒ  | d <n  z t j |  d | | } Wd | d k	 rú | j ƒ  n  X| S(   sŠ   
    Utility function to work around windows behavior that open windows.

    :see: call_subprocess_Popen and output_subprocess_Popen
    t   ntt   shellt    t   stdint   startupinfoN(   t   Nonet   ost   namet
   subprocesst   STARTUPINFOt   dwFlagst   STARTF_USESHOWWINDOWt   AttributeErrort   _subprocesst   Truet
   isinstancet   listt   joint   opent   devnullt   filenot   Popent   close(   t   commandt   paramsR   R   t   proc(    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/windows.pyt   subprocess_Popen   s&    
c         K` s…   d | k s d | k r' t  d ƒ ‚ n  t t j d ƒ F } | j d | ƒ | | d <| | d <t |  |  } | j ƒ  } Wd QX| S(   s[   
    Calls subprocess_Popen and discards the output, returning only the
    exit code.
    t   stdoutt   stderrs5   don't use stderr or stdout with call_subprocess_Popent   wbR   N(   t	   TypeErrorR   R	   R   t
   setdefaultR   t   wait(   R   R   t   nullt   pt
   returncode(    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/windows.pyt   call_subprocess_Popen2   s    

c         K` sj   d | k s d | k r' t  d ƒ ‚ n  t j | d <t j | d <t |  |  } | j ƒ  } | | j f S(   s[   
    Calls subprocess_Popen, returning the output, error and exit code
    in a tuple.
    R   R   s7   don't use stderr or stdout with output_subprocess_Popen(   R!   R   t   PIPER   t   communicateR&   (   R   R   R%   t   out(    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/windows.pyt   output_subprocess_PopenD   s    (	   t
   __future__R    R   R   R	   R   R   R'   R+   (    (    (    s3   /tmp/pip-build-X4mzal/theano/theano/misc/windows.pyt   <module>   s
   	,	