σ
ωΌςec           @@  sk  d  d l  m 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	 d  d l
 m Z d  d l m Z m Z d  d l m Z d  d l m Z m Z d  d	 l m Z e rd  d
 l m Z m Z m Z m Z m Z m Z m Z m Z e e e e f Z  n  d Z! d   Z" d   Z# d   Z$ d   Z% e& d d d d d d d e( e& d 
 Z) d   Z* d S(   i    (   t   absolute_importN(   t   shlex_quote(   t   SpinnerInterfacet   open_spinner(   t   InstallationSubprocessError(   t   console_to_strt   str_to_display(   t   subprocess_logger(   t
   HiddenTextt   path_to_display(   t   MYPY_CHECK_RUNNING(   t   Anyt   Callablet   Iterablet   Listt   Mappingt   Optionalt   Textt   Unions(   ----------------------------------------c          G@  sG   g  } x: |  D]2 } t  | t  r2 | j |  q | j |  q W| S(   s&   
    Create a CommandArgs object.
    (   t
   isinstancet   listt   extendt   append(   t   argst   command_argst   arg(    (    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   make_command   s    c         C@  s   d j  d   |  D  S(   s/   
    Format command arguments for display.
    t    c         s@  s<   |  ]2 } t  | t  r* t t |   n	 t |  Vq d  S(   N(   R   R   R   t   str(   t   .0R   (    (    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pys	   <genexpr>6   s   (   t   join(   R   (    (    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   format_command_args+   s    
c         C@  s/   g  |  D]$ } t  | t  r% | j n | ^ q S(   s=   
    Return the arguments in their raw, unredacted form.
    (   R   R   t   secret(   R   R   (    (    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   reveal_command_args;   s    c   	      C@  ss   t  |   } t | d d } t |  } d j |  } d j d | d | d | d t |  d	 | d
 t  } | S(   s§   
    Create and return the error message to use to log a subprocess error
    with command output.

    :param lines: A list of lines, each ending with a newline.
    t   descs   command bytest    u   Command errored out with exit status {exit_status}:
 command: {command_display}
     cwd: {cwd_display}
Complete output ({line_count} lines):
{output}{divider}t   exit_statust   command_displayt   cwd_displayt
   line_countt   outputt   divider(   R   R   R	   R   t   formatt   lent   LOG_DIVIDER(	   t   cmd_argst   cwdt   linesR$   t   commandR%   R&   R(   t   msg(    (    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   make_subprocess_output_errorE   s    		t   raisec         C@  sλ  | d	 k r g  } n  | d	 k r* g  } n  | rE t j } t j } n t j } t j } t j   | k } | oy | d	 k	 } | d	 k r t |   } n  | d |  t	 j
 j   } | rΙ | j |  n  x | D] } | j | d	  qΠ WyO t j t |   d t j d t j d |
 s t j n t j d | d | } Wn2 t k
 rm} |	 rgt j d | |  n    n Xg  } |
 sT| j st  | j st  | j j   xo t rt | j j    } | sΝPn  | j   } | j | d  | |  | r¨| st  | j   q¨q¨Wz | j   Wd	 | j rA| j j   n  Xd
 j  |  } n | j!   \ } } t |  } x | j"   D] } | |  qW| j |  t |  } x | j"   D] } | |  qΉW| j |  | } | j# oυ| j# | k } | r0| s
t  | r | j$ d  q0| j$ d  n  | rη| d k r| r|	 rt% d |  d | d | d | j#  } t j& |  n  t' | j# |   qη| d k rΐt j( d | | j# |  qη| d k rΟqηt) d j* |    n  | S(   sΝ  
    Args:
      show_stdout: if true, use INFO to log the subprocess's stderr and
        stdout streams.  Otherwise, use DEBUG.  Defaults to False.
      extra_ok_returncodes: an iterable of integer return codes that are
        acceptable, in addition to 0. Defaults to None, which means [].
      unset_environ: an iterable of environment variable names to unset
        prior to calling subprocess.Popen().
      log_failed_cmd: if false, failed commands are not logged, only raised.
      stdout_only: if true, return only stdout, else return both. When true,
        logging of both stdout and stderr occurs when the subprocess has
        terminated, else logging occurs as subprocess output is produced.
    s   Running command %st   stdint   stdoutt   stderrR.   t   envs#   Error %s while executing command %ss   
NR#   t   errort   doneR3   R-   R/   R$   t   warns$   Command "%s" had error code %s in %st   ignores!   Invalid value: on_returncode={!r}(+   t   NoneR   t   infot   loggingt   INFOt   debugt   DEBUGt   getEffectiveLevelR   t   ost   environt   copyt   updatet   popt
   subprocesst   PopenR!   t   PIPEt   STDOUTt	   Exceptiont   criticalR5   t   AssertionErrorR4   t   closet   TrueR   t   readlinet   rstripR   t   spint   waitR   t   communicatet
   splitlinest
   returncodet   finishR2   R8   R   t   warningt
   ValueErrorR*   (   t   cmdt   show_stdoutR.   t   on_returncodet   extra_ok_returncodest   command_desct   extra_environt   unset_environt   spinnert   log_failed_cmdt   stdout_onlyt   log_subprocesst
   used_levelt   showing_subprocesst   use_spinnerR7   t   namet   proct   exct
   all_outputt   lineR(   t	   out_bytest	   err_bytest   outt   out_linet   errt   err_linet   proc_had_errorR1   (    (    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   call_subprocesso   s²    								
	
	c         @  s   d d   f d  } | S(   sά   Provide a subprocess_runner that shows a spinner message.

    Intended for use with for pep517's Pep517HookCaller. Thus, the runner has
    an API that matches what's expected by Pep517HookCaller.subprocess_runner.
    c         @  s5   t     # } t |  d | d | d | Wd  QXd  S(   NR.   R`   Rb   (   R   Ru   (   R[   R.   R`   Rb   (   t   message(    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   runner  s    N(   R<   (   Rv   Rw   (    (   Rv   sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   runner_with_spinner_message  s    
(+   t
   __future__R    R>   RC   RH   t   pip._vendor.six.movesR   t   pip._internal.cli.spinnersR   R   t   pip._internal.exceptionsR   t   pip._internal.utils.compatR   R   t   pip._internal.utils.loggingR   t   pip._internal.utils.miscR   R	   t   pip._internal.utils.typingR
   t   typingR   R   R   R   R   R   R   R   R   t   CommandArgsR,   R   R   R!   R2   t   FalseR<   RP   Ru   Rx   (    (    (    sK   /navires/venv/lib/python2.7/site-packages/pip/_internal/utils/subprocess.pyt   <module>   s:   :			
	,