ó
ú—7Tc           @   sO  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l	 m
 Z
 d d l m Z d d l m Z d d l m Z m Z m Z m Z m Z d d l m Z d d	 l m Z m Z d d
 l m Z m Z m Z m Z m Z d d l  m! Z! d g Z" d e# f d „  ƒ  YZ$ d d „ Z& d d „ Z' d S(   s(   Base Command class, and related routinesiÿÿÿÿN(   t
   cmdoptions(   t   running_under_virtualenv(   t   logger(   t
   PipSession(   t
   BadCommandt   InstallationErrort   UninstallationErrort   CommandErrort   PreviousBuildDirError(   t   StringIO(   t   ConfigOptionParsert   UpdatingDefaultsHelpFormatter(   t   SUCCESSt   ERRORt   UNKNOWN_ERRORt   VIRTUALENV_NOT_FOUNDt   PREVIOUS_BUILD_DIR_ERROR(   t   get_progt   Commandc           B   sG   e  Z d Z d Z e Z d  „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(   c         C   s²   i |  j  d 6d t ƒ  |  j f d 6t ƒ  d 6t d 6|  j d 6|  j d 6} t |   |  _ d |  j j ƒ  } t	 j
 |  j | ƒ |  _ t j t j |  j ƒ } |  j j | ƒ d  S(	   Nt   usages   %s %st   progt	   formattert   add_help_optiont   namet   descriptions
   %s Options(   R   R   R   R   t   Falset   __doc__R
   t   parsert
   capitalizet   optparset   OptionGroupt   cmd_optsR    t   make_option_groupt   general_groupt   add_option_group(   t   selft	   parser_kwt   optgroup_namet   gen_opts(    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyt   __init__   s    


c         C   sv   t  ƒ  } | j r! | j | _ n  | j r9 | j | _ n  | j rb i | j d 6| j d 6| _ n  | j | j _ | S(   Nt   httpt   https(	   R   t   certt   verifyt   timeoutt   proxyt   proxiest   no_inputt   autht	   prompting(   R#   t   optionst   session(    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyt   _build_session3   s    				
c         C   s   d  S(   N(    (   R#   (    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyt   setup_loggingJ   s    c         C   s   |  j  j | ƒ S(   N(   R   t
   parse_args(   R#   t   args(    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyR6   M   s    c         C   sÞ  |  j  | ƒ \ } } d } | | j 7} | | j 8} t j d | ƒ } g  } t j | t j f t j | j	 f ƒ | j
 rˆ t t _ n  |  j ƒ  | j r« d t j d <n  | j rÐ d j | j ƒ t j d <n  | j rt ƒ  st j d ƒ t j t ƒ qn  | j r6t | j d ƒ } t j t j | f ƒ n d  } t } t } y. |  j | | ƒ } t | t ƒ ru| } n  Wn®t  k
 rÌt j! ƒ  d }	 t j t" |	 ƒ ƒ t j# d	 t$ ƒ  ƒ t } t% } n[t& t' f k
 r%t j! ƒ  d }	 t j t" |	 ƒ ƒ t j# d	 t$ ƒ  ƒ t } t( } nt) k
 rxt j! ƒ  d }	 t j t" |	 ƒ ƒ t j# d	 t$ ƒ  ƒ t } t( } n¯ t* k
 rÃt j! ƒ  d }	 t j d
 |	 ƒ t j# d	 t$ ƒ  ƒ t( } nd t+ k
 r t j d ƒ t j# d	 t$ ƒ  ƒ t } t( } n' t j d t$ ƒ  ƒ t } t, } n X| rÁ| j- }
 d j | ƒ } y t |
 d ƒ } Wn; t. k
 r•t/ j0 d t ƒ } | j1 }
 t |
 d ƒ } n Xt j d |
 ƒ | j2 | ƒ | j3 ƒ  n  | d  k	 rÚ| j3 ƒ  n  | S(   Ni   i   t   1t   PIP_NO_INPUTt    t   PIP_EXISTS_ACTIONs2   Could not find an activated virtualenv (required).t   as   Exception information:
%ss	   ERROR: %ss   Operation cancelled by users   Exception:
%ss   
t   wt   deletes#   Storing debug log for failure in %s(4   R6   t   verboset   quietR   t   level_for_integert   add_consumerst   syst   stdoutt   DEBUGt   appendt   log_explicit_levelst   Truet   explicit_levelsR5   R/   t   ost   environt   exists_actiont   joint   require_venvR   t   fatalt   exitR   t   logt   open_logfilet   NoneR   R   t   runt
   isinstancet   intR   t   exc_infot   strt   infot
   format_excR   R   R   R   R   R   t   KeyboardInterruptR   t   log_filet   IOErrort   tempfilet   NamedTemporaryFileR   t   writet   close(   R#   R7   R2   t   levelt   complete_logt   log_fpRP   t	   store_logt   statust   et   log_file_fnt   textt   log_file_fpt   temp(    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyt   mainQ   sš    	
										
		N(   t   __name__t
   __module__RS   R   R   R   t   hiddenR'   R4   R5   R6   Rl   (    (    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyR      s   				c         C   sG   |  d  k r t j ƒ  }  n  t ƒ  } t j |  t d | ƒ Ž  | j ƒ  S(   Nt   file(   RS   RC   RW   R	   t	   tracebackt   print_exceptiont   dictt   getvalue(   RW   t   out(    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyRZ   °   s
    	R<   c         C   sÂ   t  j j |  ƒ }  t  j j |  ƒ }  t  j j |  ƒ } t  j j | ƒ sX t  j | ƒ n  t  j j |  ƒ } t |  | ƒ } | r¾ | j d d d ƒ | j d t	 j
 d t j d ƒ f ƒ n  | S(   s¯   Open the named log file in append mode.

    If the file already exists, a separator will also be printed to
    the file to separate past activity from current activity.
    s   %s
t   -i<   s   %s run on %s
i    s   %c(   RJ   t   patht
   expandusert   abspatht   dirnamet   existst   makedirst   openR`   RC   t   argvt   timet   strftime(   t   filenamet   modeRz   R{   Rd   (    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyRR   ¸   s    *((   R   RJ   RC   R^   Rq   R   R   t   pipR    t   pip.locationsR   t   pip.logR   t   pip.downloadR   t   pip.exceptionsR   R   R   R   R   t   pip.backwardcompatR	   t   pip.baseparserR
   R   t   pip.status_codesR   R   R   R   R   t   pip.utilR   t   __all__t   objectR   RS   RZ   RR   (    (    (    s>   /var/www/otrsdash.zarafa.com/venv/build/pip/pip/basecommand.pyt   <module>   s&   ((	–