ó
N_c           @   sg  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 d d l Z d d l Z d d l m Z d	 „  Z d
 „  Z d „  Z d „  Z e d „ Z e ƒ  e d k rcy e e j d d e ƒWn3 e k
 r_Z e j e d ƒ IJe j d ƒ n Xn  d S(   s4   
Entrance point for the yum command line interface.
iÿÿÿÿN(   t   Errors(   t   plugins(   t   logginglevels(   t   _(   t
   utf8_widtht   exception2msg(   t#   suppress_keyboard_interrupt_messagec            sÀ  t  j j d t ƒ ‡ ‡ f d †  } ‡ ‡ f d †  } ‡ ‡ f d †  } ‡ ‡ f d †  } ‡  ‡ ‡ f d †  } ‡  f d †  ‰ ‡  ‡ f d †  } t j d	 ƒ ‰ t j d
 ƒ ‰ y t d ƒ } WnH t k
 r	} | j t j	 k rˆ j
 t d ƒ ƒ t j d ƒ qn X| j ƒ  y t j ƒ  WnH t k
 rl} | j t j k rmˆ j
 t d ƒ ƒ t j d ƒ qmn Xt j ƒ  ‰  y ˆ  j |  ƒ WnX t j k
 r©} | | ƒ St j k
 rÅ} | | ƒ St t f k
 rä} | | ƒ SXy ˆ  j ƒ  Wn t j k
 r} | | ƒ SXy ˆ  j ƒ  \ }	 }
 Wn t j k
 rH} | | ƒ St j k
 rd} | | ƒ St j k
 rŽ} d }	 t | ƒ g }
 n. t k
 r¢| ƒ  St k
 r»} | | ƒ SX|	 d k rx$ |
 D] } ˆ j t j  d | ƒ qÏWˆ ƒ  rüd Sˆ  j! S|	 d k rGx$ |
 D] } ˆ j
 t d ƒ | ƒ qWˆ ƒ  rCd Sd S|	 d k rVnb |	 d k rsˆ ƒ  rod Sd Sˆ j
 t d ƒ |	 ƒ x |
 D] } ˆ j
 | ƒ qWˆ ƒ  r´d Sd Sˆ  j" j# r_ˆ  j" j$ d } | j% d d ƒ } t j& j' | ƒ r_t j( | t j) ƒ r_ˆ j
 t d ƒ | ƒ ˆ j
 t d ƒ ƒ ˆ j
 t d ƒ ƒ ˆ ƒ  rXd Sd Sn  ˆ j t j  t d ƒ ƒ y ˆ  j* ƒ  \ }	 }
 Wn t j k
 r­} | | ƒ St j k
 rÉ} | | ƒ St j k
 ró} d }	 t | ƒ g }
 n. t k
 r| ƒ  St k
 r } | | ƒ SX|	 d k rAˆ ƒ  r:d Sˆ  j! S|	 d k rÃx- ˆ  j+ |
 ƒ D] \ } } ˆ j
 | | ƒ q]Wˆ  j, r²ˆ  j" j- s¨ˆ j. t d ƒ ƒ n  | ƒ  n  ˆ ƒ  r¿d Sd S|	 d k rÒnE ˆ j
 t d ƒ |	 ƒ x |
 D] } ˆ j
 | ƒ qïWˆ ƒ  rd Sd Sˆ j t j  t d ƒ ƒ y ˆ  j/ ƒ  } Wn‚ t j k
 r_} | | ƒ St j k
 r{} | | ƒ St j k
 r—} | | ƒ St k
 r«| ƒ  St k
 rÄ} | | ƒ SXt0 | ƒ t0 d" ƒ k rRt1 | ƒ d k rR| \ }	 }
 x |
 D] } ˆ j
 d | ƒ qW| ƒ  |	 } ˆ  j2 r¦ˆ j. t d  ƒ ˆ  j2 ƒ q¦nT | d k  rd } ˆ  j2 r¦ˆ j. t d  ƒ ˆ  j2 ƒ q¦n ˆ j t j  t d! ƒ ƒ ˆ ƒ  r³d S| p¿ˆ  j! S(#   s2   Run the yum program from a command line interface.t   override_timec              s$   ˆ  j  t d ƒ ƒ ˆ ƒ  r  d Sd S(   Ns   

Exiting on user canceliÈ   i   (   t   criticalR   (    (   t   loggert   unlock(    s   /usr/share/yum-cli/yummain.pyt   exUserCancel*   s    	 c            sS   |  j  d k r% ˆ  j t d ƒ ƒ n ˆ  j t d ƒ t |  ƒ ƒ ˆ ƒ  rO d Sd S(   Ni    s   

Exiting on Broken Pipes   

%siÈ   i   (   t   errnoR   R   R   (   t   e(   R	   R
   (    s   /usr/share/yum-cli/yummain.pyt	   exIOError/   s    	 c            s6   t  |  ƒ } | r% ˆ  j d | ƒ n  ˆ ƒ  r2 d Sd S(   so   Called when a plugin raises PluginYumExit.

        Log the plugin's exit message if one was supplied.
        s   

%siÈ   i   (   R   t   warn(   R   t   exitmsg(   R	   R
   (    s   /usr/share/yum-cli/yummain.pyt   exPluginExit7   s    	 c            s*   ˆ  j  d t |  j ƒ ƒ ˆ ƒ  r& d Sd S(   Ns   

%siÈ   i   (   R   R   t   value(   R   (   R	   R
   (    s   /usr/share/yum-cli/yummain.pyt   exFatalB   s    	 c            sµ   y ˆ  j  ƒ  Wn t j k
 r$ n Xt d ƒ } t d ƒ } t d ƒ } t |  d ƒ rs |  j j } |  j j } n  | i | d 6| d 6} ˆ j d | t	 |  ƒ ƒ ˆ ƒ  r± d Sd S(	   Ns§   One of the configured repositories failed (%(repo)s),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=%(repoid)s ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable %(repoid)s
        or
            subscription-manager repos --disable=%(repoid)s

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=%(repoid)s.skip_if_unavailable=true
t   Unknowns   <repoid>t   repot   repoids   

%s
%siÈ   i   (
   t   cleanExpireCacheR    t   YumBaseErrorR   t   hasattrR   t   idt   nameR   R   (   R   t   msgt   repouiR   (   t   baseR	   R
   (    s   /usr/share/yum-cli/yummain.pyt   exRepoErrorG   s     		 c             s6   y ˆ  j  ƒ  ˆ  j ƒ  Wn t j k
 r1 }  d SXd S(   NiÈ   i    (   t
   closeRpmDBt   doUnlockR    t	   LockError(   R   (   R   (    s   /usr/share/yum-cli/yummain.pyR
   ~   s    
c             sz   y ˆ  j  d ˆ j d t ƒ }  Wn8 t j k
 rY } ˆ j t d ƒ t | ƒ ƒ g  }  n X|  sv ˆ j t d ƒ ƒ n  d  S(   Nt   outR   s    Yum checks failed: %ss4    You could try running: rpm -Va --nofiles --nodigest(   t   _rpmdb_warn_checkst   infot   FalseR    R   R   R   (   t   probsR   (   R   t   verbose_logger(    s   /usr/share/yum-cli/yummain.pyt   rpmdb_warn_checks†   s    
s   yum.mains   yum.verbose.maint   .s8   No read/execute access in current directory, moving to /t   /s4   No getcwd() access in current directory, moving to /i   i    s   %siÈ   s	   Error: %si   id   s    Unknown Error(s): Exit Code: %d:i   s   /usrs   //s   No write access to %s directorys      Maybe this is an ostree image?s3     To disable you can use --setopt=usr_w_check=falses   Resolving Dependenciess=    You could try using --skip-broken to work around the problems   
Dependencies ResolvedsC   Your transaction was saved, rerun it with:
 yum load-transaction %ss	   Complete!(   i    (3   t   yumt   misct   setup_localet   Truet   loggingt	   getLoggert   opent   IOErrorR   t   EACCESR   R   t   ost   chdirt   closet   getcwdt   OSErrort   ENOENTt   clit
   YumBaseClit   getOptionsConfigR   t   PluginYumExitR    R   t   waitForLockt
   doCommandst	   RepoErrorR   t   KeyboardInterruptt   logR   t   INFO_2t	   exit_codet   conft   usr_w_checkt   installroott   replacet   patht   existst   accesst   W_OKt   buildTransactiont   pretty_output_restringt   _depsolving_failedt   skip_brokenR%   t   doTransactiont   typet   lent   _ts_save_file(   t   argsR   R   R   R   R   R)   t   fR   t   resultt
   resultmsgsR   t   usrinstpatht   prefixt   return_code(    (   R   R	   R
   R(   s   /usr/share/yum-cli/yummain.pyt   main%   s*   7





	 	 	 	 	 

	 	
	 	 


*	 	 	 c         O   sf   d d l  } t j j d ƒ } | j | ƒ } | j |  | | Ž } | j ƒ  t | j j	 | ƒ ƒ | S(   s    Profile the given function using the hotshot profiler.

    :param func: the function to profile
    :return: the return code given by the hotshot profiler
    iÿÿÿÿNs
   ~/yum.prof(
   t   hotshot.statsR5   RJ   t
   expandusert   Profilet   runcallR7   t   print_statst   statst   load(   t   funcRV   t   kwargst   hotshott   fnt   proft   rc(    (    s   /usr/share/yum-cli/yummain.pyRg   <  s    
c         O   so   d d l  } d d l } t j j d ƒ } | j ƒ  } | j |  | | Ž } | j | ƒ t | j	 | ƒ ƒ | S(   sœ   Profile the given function using the cprof profiler.

    :param func: the function to profile
    :return: the return code given by the cprof profiler
    iÿÿÿÿNs
   ~/yum.prof(
   t   cProfilet   pstatsR5   RJ   R_   R`   Ra   t
   dump_statsRb   t   Stats(   Re   RV   Rf   Rk   Rl   Rh   Ri   Rj   (    (    s   /usr/share/yum-cli/yummain.pyt   cprofJ  s    c         C   sE   |  j  ƒ  |  j d d ƒ |  j d ƒ |  j d ƒ |  j d ƒ d S(   s   Print out information from a :class:`Stats` object.

    :param stats: the :class:`Stats` object to print information from
    t   timet   callsi   t
   cumulativei(   N(   t
   strip_dirst
   sort_statsRb   (   Rc   (    (    s   /usr/share/yum-cli/yummain.pyRb   X  s
    
c         C   sÈ   d } d t j k rb t j d d k r: t t |  ƒ } n  t j d d k rb t t |  ƒ } qb n  d t j k r“ d d l } | j t |  ƒ ƒ n  | d k r® t |  ƒ } n  | rÄ t j	 | ƒ n  | S(   sl  Call one of the multiple main() functions based on environment variables.

    :param args: command line arguments passed into yum
    :param exit_code: if *exit_code* is True, this function will exit
       python with its exit code when it has finished executing.
       Otherwise, it will return its exit code.
    :return: the exit code from yum execution
    t   YUM_PROFRo   Rg   t   YUM_PDBiÿÿÿÿN(
   t   NoneR5   t   environRo   R]   Rg   t   pdbt   runt   syst   exit(   RV   RE   t   errcodeRy   (    (    s   /usr/share/yum-cli/yummain.pyt	   user_mainc  s    	t   __main__i   RE   s   

Exiting on user cancel.(    t   __doc__R5   t   os.pathR{   R0   Rp   R   R,   R    R   R   R   t   yum.i18nR   R   t   yum.miscR;   t   utilsR   R]   Rg   Ro   Rb   R&   R~   t   __name__t   argvR/   RB   R   t   stderrR|   (    (    (    s   /usr/share/yum-cli/yummain.pyt   <module>   s6   	ÿ 			