ó
Ý²k^c           @` s›  d  d l  m Z m Z m Z m Z d  d l m Z m Z m Z d  d l	 m
 Z
 d  d l Z d  d l m Z m Z m Z m Z m Z m Z d  d l Z d  d l m Z d  d l m Z m Z d d	 l m Z m Z m 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& d d l' m( Z( e
 e) ƒ Z* e j+ d ƒ Z, d e- f d „  ƒ  YZ. d „  Z/ e0 d „ Z1 e0 d „ Z2 e0 e0 d „ Z3 d S(   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   EINVALt   EXDEVt   EPERM(   t	   getLoggerN(   t   dirnamet   isdirt   splitt   basenamet   joint   exists(   t   move(   t   Popent   PIPEi   (   t   exp_backoff_fnt   mkdir_pt   mkdir_p_sudo_safe(   t   rm_rf(   t   lexistsi   (   t   context(   t   on_win(   t   expand(   t   NotWritableErrors   ^(#!((?:\\ |[^ \n\r])+)(.*))t   CancelOperationc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s9   lib/python2.7/site-packages/conda/gateways/disk/update.pyR      s   c         C` s•   d  } zt t t |  d ƒ } t j d |  ƒ | j ƒ  } | j d ƒ y! | j | | ƒ ƒ | j ƒ  Wn t	 k
 rx n XWd  | r | j
 ƒ  n  Xd  S(   Nu   rb+u"   in-place update path locked for %si    (   t   NoneR   t   opent   logt   tracet   readt   seekt   writet   truncateR   t   close(   t   file_full_patht   callbackt   fht   data(    (    s9   lib/python2.7/site-packages/conda/gateways/disk/update.pyt   update_file_in_place_as_binary   s    c         C` s–  t  | ƒ r | r t | ƒ n  t  |  ƒ r‚t j d |  | ƒ y t j |  | ƒ Wq’t k
 r~} t r7t |  ƒ t | ƒ k r7t j	 j
 |  ƒ r7t t j d ƒ } t | d ƒ } t | ƒ rt |  ƒ \ } } t | ƒ } t d d | | | | g d t d t ƒ}	 |	 j ƒ  \ }
 } q{t j d j | ƒ ƒ q| j t t t f k rxt j d	 |  | | j ƒ t |  | ƒ q‚  q’Xn t j d
 |  ƒ d  S(   Nu   renaming %s => %su   condabinu   rename_tmp.batu   cmd.exeu   /Ct   stdoutt   stderrux   {} is missing.  Conda was not installed correctly or has been corrupted.  Please file an issue on the conda github repo.uH   Could not rename %s => %s due to errno [%s]. Falling back to copy/unlinku.   cannot rename; source path does not exist '%s'(   R   R   R   R    t   ost   renamet   EnvironmentErrorR   R   t   patht   isfileR   R   t   conda_prefixR   R
   R   R   R   t   communicatet   debugt   formatt   errnoR   R   R   R   (   t   source_patht   destination_patht   forcet   et   condabin_dirt   rename_scriptt   _dirnamet   _src_fnt   _dest_fnt   pR+   R,   (    (    s9   lib/python2.7/site-packages/conda/gateways/disk/update.pyR.   3   s2    	
c         C` s   t  t |  | | ƒ d  S(   N(   R   R.   (   R7   R8   R9   (    (    s9   lib/python2.7/site-packages/conda/gateways/disk/update.pyt   backoff_renameW   s    c         C` sé   y± t  |  ƒ }  t j d |  ƒ t |  ƒ r? t j |  d  ƒ t St |  ƒ } t	 | ƒ r~ | r~ | rq t
 | ƒ q– t | ƒ n t	 t |  ƒ ƒ s– t ‚ t |  d ƒ  Wd  QXt SWn1 t t f k
 rä } t |  | j d | ƒ‚ n Xd  S(   Nu   touching path %su   at	   caused_by(   R   R   R    R   R-   t   utimeR   t   TrueR   R	   R   R   t   AssertionErrorR   t   Falset   IOErrort   OSErrorR   R6   (   R0   t   mkdirt	   sudo_safet   dirpathR:   (    (    s9   lib/python2.7/site-packages/conda/gateways/disk/update.pyt   touch[   s"    
(4   t
   __future__R    R   R   R   R6   R   R   R   t   loggingR   R-   t   os.pathR   R	   R
   R   R   R   t   ret   shutilR   t
   subprocessR   R   t    R   R   R   t   deleteR   t   linkR   t   base.contextR   t   common.compatR   t   common.pathR   t
   exceptionsR   R   R   t   compilet   SHEBANG_REGEXt	   ExceptionR   R*   RF   R.   RA   RL   (    (    (    s9   lib/python2.7/site-packages/conda/gateways/disk/update.pyt   <module>   s*   ".	$