??????????????????????
???  ?????????????????
 JFIF      ?? C      


!"$"$?? C    
?? p 
" ??     
         ??             ?   
   ????

(%	aA*?XYD?(J??E  RE,P XYae?)(E  2 B  R  	BQ    X?)X     ?  @  

adadasdasdasasdasdas


.....................................................................................................................................??????????????????????
???  
 JFIF      ?? C      


!"$"$?? C    
?? p 
" ??     
         ??             ?   
   ????

(%	aA*?XYD?(J??E  RE,P XYae?)(E  2 B  R  	BQ    X?)X     ?  @  

adadasdasdasasdasdas


.....................................................................................................................................ó
 ˆ”^c           @   s=  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 m Z d d l m	 Z	 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 m Z m Z m Z m Z d a d	 „  Z e e d
 „ ƒ Z d „  Z d e f d „  ƒ  YZ d „  Z d e
 f d „  ƒ  YZ d „  Z  d „  Z! d S(   s\   
    This module provides classes and functions used to download and manage
    debuginfos.
iÿÿÿÿN(   t   Popen(   t   _t   YumBase(   t   DownloadBaseCallback(   t   YumBaseError(	   R   t   log1t   log2t	   RETURN_OKt   RETURN_FAILUREt   RETURN_CANCEL_BY_USERt   verboset
   ask_yes_not	   error_msgt    c            sq   d d l  } t j ƒ  ‰ t j ƒ  ‰ | j d ƒ ‰  ˆ  j ˆ k rU ˆ  j ˆ k rU ˆ S‡  ‡ ‡ ‡ f d †  } | S(   s·   
    Ensures that the function is called using abrt's uid and gid

    Returns:
        Either an unchanged function object or a wrapper function object for
        the function.
    iÿÿÿÿNt   abrtc             sM   t  j ˆ  j ƒ t  j ˆ  j ƒ ˆ |  | Ž  } t  j ˆ ƒ t  j ˆ ƒ | S(   só   
        Wrapper function around the called function.

        Sets up uid and gid to match abrt's and after the function finishes
        rolls its uid and gid back.

        Returns:
            Return value of the wrapped function.
        (   t   ost   setegidt   pw_gidt   seteuidt   pw_uid(   t   argst   kwargst   retval(   R   t   current_gidt   current_uidt   fn(    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   wrapped)   s    (   t   pwdR   t   getuidt   getgidt   getpwnamR   R   (   R   R   R   (    (   R   R   R   R   s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   ensure_abrt_uid   s    	c         C   s%  | d |  } t  d | | ƒ t d | ƒ t d ƒ j | ƒ GH| d } y t | d ƒ } Wn+ t k
 r‰ }	 t d ƒ j | |	 ƒ GHt SXt d | g d	 | d
 d ƒ}
 |
 j ƒ  } | d k rð t  d ƒ | st  d | ƒ t	 j
 | ƒ qn" | j ƒ  t d ƒ j | ƒ GHt S| j ƒ  t | d ƒ } t d ƒ j d |  ƒ GHd } d d g } | r•x  | D] } | d | d 7} qaWd d | j ƒ  g } n  t d d ƒ = } t | d | d
 d d | d	 | d | ƒ} | j ƒ  } Wd QX| d k r	t  d ƒ t	 j
 | ƒ n t d ƒ j | ƒ GHt Sd S(    sþ  
    Unpacks a single rpm located in tmp_dir into destdir.

    Arguments:
        package_file_name - name of the rpm file
        files - files to extract from the rpm
        tmp_dir - temporary directory where the rpm file is located
        destdir - destination directory for the rpm package extraction
        keeprpm - check if the user wants to delete rpms from the tmp directory
        exact_files - extract only specified files

    Returns:
        RETURN_FAILURE in case of a serious problem
    t   /s   Extracting %s to %ss   %ss   Extracting cpio from {0}s   /unpacked.cpiot   wbs   Can't write to '{0}': {1}t   rpm2cpiot   stdoutt   bufsizeiÿÿÿÿi    s   cpio written OKs   keeprpms = False, removing %ss   Can't extract package '{0}'t   rbs$   Caching files from {0} made from {1}s   unpacked.cpioR   t   cpios   -idut   .t    s	   /dev/nullt   wt   cwdt   stdint   stderrNs   files extracted OKs   Can't extract files from '{0}'(   R   R   R   t   formatt   opent   IOErrorR   R    t   waitR   t   unlinkt   closet   strip(   t   package_file_namet   filest   tmp_dirt   destdirt   keeprpmt   exact_filest   package_full_patht   unpacked_cpio_patht   unpacked_cpiot   exR"   t   retcodet   file_patternst	   cpio_argst   filenamet   nullR&   (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt
   unpack_rpmC   sN    




c          C   se   t  ra y t j t  ƒ Wqa t k
 r] }  |  j t j k r^ t t d ƒ j t  |  ƒ ƒ q^ qa Xn  d S(   s*   
    Removes the temporary directory.
    s   Can't remove '{0}': {1}N(	   t   TMPDIRt   shutilt   rmtreet   OSErrort   errnot   ENOENTR   R   R-   (   R=   (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   clean_up‰   s    t   MyDownloadCallbackc           B   s    e  Z d  Z d „  Z d „  Z RS(   sR   
    This class serves as a download progress handler for yum's progress bar.
    c         C   s5   | |  _  d |  _ d |  _ d |  _ t j |  ƒ d S(   sx   
        Sets up instance variables

        Arguments:
            total_pkgs - number of packages to download
        i    N(   t
   total_pkgst   downloaded_pkgst   last_pctt	   last_timeR   t   __init__(   t   selfRL   (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyRP   š   s
    				c         C   sY  t  | d ƒ } | |  j k r- t d ƒ d S| |  _ t j j ƒ  r¨ t j j d |  j d |  j | | f ƒ | d k rHt	 d ƒ j
 |  j d |  j | | ƒ GHqHn  t j ƒ  } |  j d k rÏ | |  _ n  | d k sý |  j | k sý | |  j d k rHt	 d ƒ j
 |  j d |  j | | ƒ GH| |  _ | d k rHd |  _ qHn  t j j ƒ  d S(	   s  
        A method used to update the progress

        Arguments:
            name - filename
            frac - progress fracment (0 -> 1)
            fread - formated string containing BytesRead
            ftime - formated string containing remaining or elapsed time
        id   s-   percentage is the same, not updating progressNs&   [sDownloading (%i of %i) %s: %3u%%[ui   s$   Downloading ({0} of {1}) {2}: {3:3}%i    i   (   t   intRN   R   t   sysR#   t   isattyt   writeRM   RL   R   R-   t   timeRO   t   flush(   RQ   t   namet   fract   freadt   ftimet   pctt   t(    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   updateProgress¨   s*    
	!.	(   t   __name__t
   __module__t   __doc__RP   R^   (    (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyRK   •   s   	c         C   s(   t  d ƒ j |  j |  j ƒ GHi d d 6S(   s0   
    A callback function for mirror errors.
    sO   Problem '{0!s}' occured while downloading from mirror: '{1!s}'. Trying next onei    t   fail(   R   R-   t	   exceptiont   mirror(   t   callBackObj(    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   downloadErrorCallback×   s    t   DebugInfoDownloadc           B   sM   e  Z d  Z d e e d „ Z d „  Z d „  Z e d „  ƒ Z	 e d „ Z
 RS(   s>   
    This class is used to manage download of debuginfos.
    s   *debug*c         C   s¸   d |  _  | |  _ | |  _ | a | |  _ | |  _ | |  _ t j |  ƒ |  j	 ƒ  t
 d ƒ GHy |  j ƒ  Wn; t k
 r© } |  j ƒ  t
 d ƒ j | ƒ GHt d ƒ n X|  j ƒ  d  S(   Niÿÿÿÿs   Initializing yums7   Error initializing yum (YumBase.doConfigSetup): '{0!s}'i   (   t
   old_stdoutt   cachedirt   tmpdirRD   t   keeprpmst   noninteractivet   repo_patternR   RP   t   mute_stdoutR   t   doConfigSetupR   t   unmute_stdoutR-   t   exit(   RQ   t   cachet   tmpRm   t	   keep_rpmsRl   R=   (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyRP   ç   s"    						

c         C   s1   t  d k  r- t j |  _ t d d ƒ t _ n  d S(   sJ   
        Links sys.stdout with /dev/null and saves the old stdout
        i   s	   /dev/nullR)   N(   R
   RS   R#   Rh   R.   (   RQ   (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyRn     s    c         C   s6   t  d k  r2 |  j d k r* |  j t _ q2 d GHn  d S(   s@   
        Replaces sys.stdout by stdout saved using mute
        i   iÿÿÿÿs    ERR: unmute called without mute?N(   R
   Rh   RS   R#   (   RQ   (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyRp     s    c         C   sœ   t  j j |  j ƒ sL y t  j |  j ƒ WqL t k
 rH } d | GHt SXn  t  j j |  j ƒ s˜ y t  j |  j ƒ Wq˜ t k
 r” } d | GHt SXn  t S(   Ns   Can't create tmpdir: %ss   Can't create cachedir: %s(	   R   t   patht   existsRj   t   makedirsRG   R   Ri   R   (   RQ   R=   (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   setup_tmp_dirs  s    		c         C   s­  d } d } d } d } | s" t  S|  j ƒ  s= t d ƒ GHt  Sxn |  j j ƒ  D]] } y! | j ƒ  |  j j | j ƒ WqM t k
 r© } t d ƒ j	 | j t
 | ƒ ƒ GHqM XqM Wt d ƒ GHxõ |  j j d |  j ƒ D]Û }	 y’ |  j j |	 j ƒ }
 |  j j d t
 |	 j ƒ ƒ t d |
 ƒ t |	 d t ƒ y t |	 d	 t ƒ Wn) t t f k
 rh} | GHt d
 ƒ GHn XWqÒ t k
 r¬} t d ƒ j	 |	 j | ƒ GH|  j j |	 j ƒ qÒ XqÒ Wt d ƒ GHy |  j j d d d d ƒ Wn' t k
 r} t d ƒ j	 | ƒ GHn Xy |  j j d d d d ƒ Wn' t k
 rI} t d ƒ j	 | ƒ GHn Xg  } i  } xÛ | D]Ó } t d | ƒ |  j j | ƒ } | r| d | j ƒ  k r¶| | d j | ƒ nI | g | | d <| t | d j ƒ 7} | t | d j ƒ 7} | d 7} t d | | d ƒ q]t d | ƒ | j | ƒ q]Wt | ƒ } |  j j | ƒ |  j j  t! ƒ t" d k s~t# | ƒ d k r›t d ƒ j	 t# | ƒ ƒ GHn  t" d k s³| d k r1t d ƒ j	 | ƒ GHt d ƒ j	 | d. | d/ ƒ } |  j$ t k rt% | ƒ rt d ƒ GHt& S|  j' ƒ  } | t( k r.| St) j* |  j+ ƒ } t | j, | j- ƒ d0 } | d1 | k r®t d ƒ j	 |  j+ | ƒ } |  j$ r®t% | ƒ r®t d ƒ GHt& Sn  t) j* |  j. ƒ } t | j, | j- ƒ d2 } | d3 | k r1t d ƒ j	 |  j. | ƒ } |  j$ r.t% | ƒ r.t d ƒ GHt& Sq1n  xø| j/ ƒ  D]ê\ } } | | _0 d | _1 | j2 d ƒ } t) j3 j4 | ƒ } |  j' ƒ  } | t( k r™| S| j2 d ƒ } d4 } | j6 d  ƒ r| d! } t d" | ƒ y t7 j8 | |  j+ ƒ WqTt9 k
 r} t d# ƒ j	 | | ƒ GHq>qTXn6 t) j3 j: |  j+ | ƒ } | | _; |  j< d$ | g ƒ } | j= d% | j> d% | j? d& | j@ } | d' } | rÕy t) jA |  j+ d( | ƒ Wn t9 k
 r½n Xt d) ƒ j	 | ƒ GHnI tB | | |  j+ |  j. |  jC d* | ƒ} | t  k rt d+ ƒ GHtD ƒ  t  S| d 7} q>W|  jC r©t) j3 jE |  j+ ƒ r©t d, ƒ j	 |  j+ ƒ GHy t) jF |  j+ ƒ Wq©t9 k
 r¥tG t d- ƒ j	 |  j+ ƒ ƒ q©Xn  t( S(5   s¢  
        Downloads rpms into a temporary directory

        Arguments:
            package_files_dict - a dict containing {pkg: file list} entries
            total_pkgs - total number of packages to download
            download_exact_files - extract only specified files

        Returns:
            RETURN_OK if all goes well.
            RETURN_FAILURE in case it cannot set up either of the directories.
        i    s#   Error: can't make cachedir, exitings'   Can't disable repository '{0!s}': {1!s}s   Setting up yum repositoriest   patternt   thisrepos   enabled repo %st   skip_if_unavailablet   _asyncsA   Can't disable async download, the output might contain artifacts!s   Can't setup {0}: {1}, disablings+   Looking for needed packages in repositoriest   mdtypet   metadatat	   cacheonlyi   s"   Error retrieving metadata: '{0!s}'t	   filelistss#   Error retrieving filelists: '{0!s}'s   yum whatprovides %ss   found pkg for %s: %ss   not found pkg for %ss+   Can't find packages for {0} debuginfo filess   Packages to download: {0}s;   Downloading {0:.2f}Mb, installed size: {1:.2f}Mb. Continue?i   s   Download cancelled by usersK   Warning: Not enough free space in tmp dir '{0}' ({1:.2f}Mb left). Continue?sM   Warning: Not enough free space in cache dir '{0}' ({1:.2f}Mb left). Continue?t   relativepatht
   remote_urls   file:///i   s   copying from local repo: %ss   Cannot copy file '{0}': {1}t   pkglistt   -R'   s   .rpmR    s   Downloading package {0} failedR9   s&   Unpacking failed, aborting download...s   Removing {0}s/   Can't remove %s, probably contains an error logi   i   i   i   i   i   N(H   R   t   setCacheDirR   t   repost   listEnabledR2   t   disableRepot   idR   R-   t   strt	   findReposRm   t
   enableRepot   doSetupR   t   setattrt   Truet   Falset	   NameErrort   AttributeErrort   populateSackR   t   pkgSackt   searchFilest   keyst   appendt   floatt   sizet   installedsizeRK   t   setProgressBart   setMirrorFailureCallbackRf   R
   t   lenRl   R   R	   Rx   R   R   t   statvfsRj   t   f_bsizet   f_bavailRi   t	   iteritemsRM   Rr   t   returnSimpleRu   t   basenamet   Nonet
   startswithRE   t   copyRG   t   joint	   localpatht   downloadPkgsRX   t   versiont   releaset   archR1   RC   Rk   RJ   Rv   t   rmdirR   (   RQ   R5   t   download_exact_filest   installed_sizeRL   t   todownload_sizeRM   t   repoR=   t   rt   ridt	   not_foundt   package_files_dictt   debuginfo_patht   pkgt   dnlcbt   questionR   t   rest	   tmp_spacet   cache_spacet   remotet   localt   remote_patht   errt   pkg_patht   pkg_nvraR4   t   unpack_result(    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   download)  s   
(	

		

	*
	#(   R_   R`   Ra   R   R   RP   Rn   Rp   R   Rx   RÄ   (    (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyRg   â   s   			c         C   s,   g  | D]! } d |  | d  | d f ^ q S(   s¥   
    Transforms build ids into a path.

    build_id1=${build_id:0:2}
    build_id2=${build_id:2}
    file="usr/lib/debug/.build-id/$build_id1/$build_id2.debug"
    s&   %s/usr/lib/debug/.build-id/%s/%s.debugi   (    (   t   pfxt	   build_idst   b_id(    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   build_ids_to_path   s    	c         C   s.  t  d |  ƒ } g  } xZ | D]R } t d | ƒ t j j | ƒ rT t d | ƒ q n  t d | ƒ | j | ƒ q W| r‡ | } g  } n | Sxœ | D]” } t d | ƒ xd | D]\ } | | } t d | ƒ t j j | ƒ rï t d | ƒ q­ n  t d | ƒ | j | ƒ q­ W| r"| } g  } q’ | Sq’ W| S(   sÐ   
    Checks for installed debuginfos.

    Arguments:
        build_ids - string containing build ids
        cache_dirs - list of cache directories

    Returns:
        List of missing debuginfo files.
    R   s   looking: %ss	   found: %ss   not found: %ss   looking in %s(   RÈ   R   R   Ru   Rv   R—   (   RÆ   t
   cache_dirsR5   t   missingR¶   t	   cache_dirt   cache_debuginfo_path(    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   filter_installed_debuginfos  s8    	
	("   Ra   RS   R   RV   RH   RE   t
   subprocessR    t   yumR   R   t   yum.callbacksR   t
   yum.ErrorsR   t   reportclientR   R   R   R   R	   R
   R   R   RD   R   R   RC   RJ   RK   Rf   Rg   RÈ   RÍ   (    (    (    s<   /usr/lib64/python2.7/site-packages/reportclient/debuginfo.pyt   <module>   s*   @	,E	B	ÿ 	