Mini Shell

Direktori : /usr/lib64/python3.6/site-packages/reportclient/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/reportclient/__pycache__/yumdebuginfo.cpython-36.pyc

3


�$`�!�@s�ddlZddlZddlmZmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZGdd�de�Zd	d
�ZGdd�de
�ZdS)
�N)�_�YumBase)�DownloadBaseCallback)�YumBaseError)�DebugInfoDownload)�log1�log2�RETURN_FAILUREc@s eZdZdZdd�Zdd�ZdS)�YumDownloadCallbackzR
    This class serves as a download progress handler for yum's progress bar.
    cCstj|�||_dS)zx
        Sets up instance variables

        Arguments:
            total_pkgs - number of packages to download
        N)r�__init__�observer)�selfr�r�$/usr/lib64/python3.6/yumdebuginfo.pyr#s
zYumDownloadCallback.__init__cCs|jj|t|d��dS)a
        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
        �dN)r�update�int)r
�nameZfracZfreadZftimerrr�updateProgress/sz"YumDownloadCallback.updateProgressN)�__name__�
__module__�__qualname__�__doc__rrrrrrr
sr
cCs$ttd�jt|j�|j��ddiS)z0
    A callback function for mirror errors.
    zOProblem '{0!s}' occured while downloading from mirror: '{1!s}'. Trying next oneZfailr)�printr�format�strZ	exceptionZmirror)ZcallBackObjrrr�downloadErrorCallback=s
rcsFeZdZd�fdd�	Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z�Z	S)�YumDebugInfoDownload�*debug*FTNcs:tt|�j|||||�t�|_|dk	r6||jjjd<dS)N�
releasever)�superrrr�baseZconfZ
substitutions)r
�cacheZtmp�repo_patternZ	keep_rpmsZnoninteractiver)�	__class__rrrKszYumDebugInfoDownload.__init__cCs,t|�|_|jjj|j�|jjjt�dS)N)r
Zprogressr!�reposZsetProgressBarZsetMirrorFailureCallbackr)r
Zupdaterrrr�initialize_progressSs
z(YumDebugInfoDownload.initialize_progressc Cs�|j�y|jj�WnHtk
r^}z,|j�ttd�jt|���t	d�WYdd}~XnX|j�|jj
�s�ttd��tSxn|jjj
�D]^}y|j�|jjj|j�Wq�tk
r�}z ttd�j|jt|���WYdd}~Xq�Xq�WdS)Nz7Error initializing yum (YumBase.doConfigSetup): '{0!s}'�z#Error: can't make cachedir, exitingz'Can't disable repository '{0!s}': {1!s})Zmute_stdoutr!Z
doConfigSetuprZ
unmute_stdoutrrrr�exitZsetCacheDirr	r%ZlistEnabled�close�disableRepo�id)r
�exZreporrr�prepareXs"
zYumDebugInfoDownload.preparecCs�x�|jjj|jd�D]�}y�|jjj|j�}|jjjt|j�d�td|�t	|dd�yt	|dd�Wn>t
tfk
r�}ztt|��tt
d��WYdd}~XnXWqtk
r�}z0tt
d	�j|jt|���|jjj|j�WYdd}~XqXqWy|jjjd
dd�Wn:tk
�rJ}ztt
d
�jt|���WYdd}~XnXy|jjjddd�Wn:tk
�r�}ztt
d�jt|���WYdd}~XnXdS)N)�pattern)Zthisrepozenabled repo %sZskip_if_unavailableTZ_asyncFzACan't disable async download, the output might contain artifacts!zCan't setup {0}: {1}, disablingZmetadatar')ZmdtypeZ	cacheonlyz"Error retrieving metadata: '{0!s}'Z	filelistsz#Error retrieving filelists: '{0!s}')r!r%Z	findReposr#Z
enableRepor+ZdoSetuprr�setattr�	NameError�AttributeErrorrrrrr*ZpopulateSack)r
�rZridr,rrr�initialize_repositoriesvs,
"&(z,YumDebugInfoDownload.initialize_repositoriescCs�g}i}d}d}x�|D]�}td|�|jjj|�}|r�|d|j�krZ||dj|�n2|g||d<|t|dj�7}|t|dj�7}td||d�qtd|�|j|�qW||||fS)Nrzyum whatprovides %szfound pkg for %s: %sznot found pkg for %s)	rr!ZpkgSackZsearchFiles�keys�append�float�sizeZ
installedsize)r
�filesZ	not_foundZpackage_files_dictZtodownload_sizeZinstalled_sizeZdebuginfo_path�pkgrrr�triage�s"


zYumDebugInfoDownload.triagecCs�|jd�}tjj|�}tjj|j|�}|jd�}d}|jd�r�|dd�}td|�ytj	||�Wq�t
k
r�}ztd�j|t
|��}WYdd}~Xq�Xn||_|jj|gd�}||fS)NZrelativepathZ
remote_urlzfile:///�zcopying from local repo: %szCannot copy file '{0}': {1})Zpkglist)ZreturnSimple�os�path�basename�joinZtmpdir�
startswithr�shutil�copy�OSErrorrrrZ	localpathr!ZdownloadPkgs)r
r9ZremoteZlocalZremote_path�errZpkg_pathr,rrr�download_package�s



(z%YumDebugInfoDownload.download_package)rFTN)
rrrrr&r-r3r:rE�
__classcell__rr)r$rrIs/r)r<rAZyumrrZ
yum.callbacksrZ
yum.ErrorsrZreportclient.debuginforZreportclientrrr	r
rrrrrr�<module>s