Your IP : 18.118.33.239


Current Path : /usr/lib/python3.6/site-packages/dnf/db/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dnf/db/__pycache__/history.cpython-36.opt-1.pyc

3

�ft`%:�@s�ddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZmZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZdS)�N)�ucd)�misc)�
DatabaseError�)�GroupPersistor�EnvironmentPersistor�RPMTransactionc@sjeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
edd��Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zed#d$��Zed%d&��Zejd'd&��Zed(d)��Zejd*d)��Zed+d,��Zed-d.��Zed/d0��Zejd1d0��Zed2d3��Zd4d5�Zed6d7��Zd8d9�Zed:d;��Z ed<d=��Z!ed>d?��Z"d@S)A�RPMTransactionItemWrappercCs||_||_dS)N)�_swdb�_item)�self�swdb�item�r�/usr/lib/python3.6/history.py�__init__#sz"RPMTransactionItemWrapper.__init__cCs|jj�j�S)N)rZgetItemZtoStr)rrrr�__str__(sz!RPMTransactionItemWrapper.__str__cCs|j|jkS)N)r)r�otherrrr�__lt__+sz RPMTransactionItemWrapper.__lt__cCs|j|jkS)N)r)rrrrr�__eq__.sz RPMTransactionItemWrapper.__eq__cCs
|jj�S)N)r�__hash__)rrrrr1sz"RPMTransactionItemWrapper.__hash__cCsdS)NTr)r�patternrrr�match4szRPMTransactionItemWrapper.matchcCs|jj�dk	S)N)r�
getRPMItem)rrrr�
is_package7sz$RPMTransactionItemWrapper.is_packagecCs|jj�dk	S)N)r�getCompsGroupItem)rrrr�is_group:sz"RPMTransactionItemWrapper.is_groupcCs|jj�dk	S)N)r�getCompsEnvironmentItem)rrrr�is_environment=sz(RPMTransactionItemWrapper.is_environmentcCs
|jj�S)N)rr)rrrr�	get_group@sz#RPMTransactionItemWrapper.get_groupcCs
|jj�S)N)rr)rrrr�get_environmentCsz)RPMTransactionItemWrapper.get_environmentcCs|jj�j�S)N)rrZgetName)rrrr�nameFszRPMTransactionItemWrapper.namecCs|jj�j�S)N)rrZgetEpoch)rrrr�epochJszRPMTransactionItemWrapper.epochcCs|jj�j�S)N)rrZ
getVersion)rrrr�versionNsz!RPMTransactionItemWrapper.versioncCs|jj�j�S)N)rrZ
getRelease)rrrr�releaseRsz!RPMTransactionItemWrapper.releasecCs|jj�j�S)N)rrZgetArch)rrrr�archVszRPMTransactionItemWrapper.archcCs*|jrdj|j|j|j�Sdj|j|j�S)Nz{}:{}-{}z{}-{})r"�formatr#r$)rrrr�evrZszRPMTransactionItemWrapper.evrcCs|jj�j�S)N)rrZgetNEVRA)rrrr�nevra`szRPMTransactionItemWrapper.nevracCs
|jj�S)N)rZ	getAction)rrrr�actiondsz RPMTransactionItemWrapper.actioncCs|jj|�dS)N)rZ	setAction)r�valuerrrr)hscCs
|jj�S)N)rZ	getReason)rrrr�reasonlsz RPMTransactionItemWrapper.reasoncCs|jj|�S)N)rZ	setReason)rr*rrrr+pscCs$y
|jj�Stk
rdSXdS)N�)rZ
getActionName�AttributeError)rrrr�action_namets
z%RPMTransactionItemWrapper.action_namecCs$y
|jj�Stk
rdSXdS)Nr,)rZgetActionShortr-)rrrr�action_short{s
z&RPMTransactionItemWrapper.action_shortcCs
|jj�S)N)r�getState)rrrr�state�szRPMTransactionItemWrapper.statecCs|jj|�dS)N)r�setState)rr*rrrr1�scCs
|jj�S)N)r�	getRepoid)rrrr�	from_repo�sz#RPMTransactionItemWrapper.from_repocCs|jj�sdSd|jj�S)Nr,�@)rr3)rrrr�ui_from_repo�s
z&RPMTransactionItemWrapper.ui_from_repocCsdS)Nr)rrrr�
obsoleting�sz$RPMTransactionItemWrapper.obsoletingcCs|jjj|�S)N)r
�rpm�
get_reason)rrrrr9�sz$RPMTransactionItemWrapper.get_reasoncCs|jjj|jS)N)r
r8Z_swdb_ti_pkgr)rrrr�pkg�szRPMTransactionItemWrapper.pkgcCs|jjS)N)r:�files)rrrrr;�szRPMTransactionItemWrapper.filescCs|jS)N)r:)rrrr�_active�sz!RPMTransactionItemWrapper._activeN)#�__name__�
__module__�__qualname__rrrrrrrrrrr �propertyr!r"r#r$r%r'r(r)�setterr+r.r/r1r4r6r7r9r:r;r<rrrrr	"sBr	c@s�eZdZdZdZdd�Zedd��Zedd��Zedd	��Z	ed
d��Z
edd
��Zedd��Zedd��Z
edd��Zedd��Zedd��Zedd��Zedd��Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(S))�TransactionWrapperFcCs
||_dS)N)�_trans)r�transrrrr�szTransactionWrapper.__init__cCs
|jj�S)N)rC�getId)rrrr�tid�szTransactionWrapper.tidcCs
|jj�S)N)rCZ
getCmdline)rrrr�cmdline�szTransactionWrapper.cmdlinecCs
|jj�S)N)rCZ
getReleasever)rrrr�
releasever�szTransactionWrapper.releasevercCs
|jj�S)N)rCZ
getDtBegin)rrrr�
beg_timestamp�sz TransactionWrapper.beg_timestampcCs
|jj�S)N)rCZgetDtEnd)rrrr�
end_timestamp�sz TransactionWrapper.end_timestampcCs
|jj�S)N)rC�getRpmdbVersionBegin)rrrr�beg_rpmdb_version�sz$TransactionWrapper.beg_rpmdb_versioncCs
|jj�S)N)rC�getRpmdbVersionEnd)rrrr�end_rpmdb_version�sz$TransactionWrapper.end_rpmdb_versioncCst|jj�tjjk�S)N)�intrCr0�libdnf�transaction�TransactionItemState_DONE)rrrr�return_code�szTransactionWrapper.return_codecCs
|jj�S)N)rCZ	getUserId)rrrr�loginuid�szTransactionWrapper.loginuidcCs|jS)N)�packages)rrrr�data�szTransactionWrapper.datacCs|jj�}t|�S)N)rC�getConsoleOutput�bool)r�outputrrr�	is_output�s
zTransactionWrapper.is_outputcCs
|jj�S)N)rCZ
getComment)rrrr�comment�szTransactionWrapper.commentcCs|jj�gS)N)rCrE)rrrr�tids�szTransactionWrapper.tidscCsgS)Nr)rrrr�performed_with�sz!TransactionWrapper.performed_withcs�jj�}�fdd�|D�S)Ncsg|]}t�|��qSr)r	)�.0�i)rrr�
<listcomp>�sz/TransactionWrapper.packages.<locals>.<listcomp>)rCZgetItems)r�resultr)rrrU�s
zTransactionWrapper.packagescCsdd�|jj�D�S)NcSsg|]}|d�qS)rr)r^r_rrrr`�sz-TransactionWrapper.output.<locals>.<listcomp>)rCrW)rrrrrY�szTransactionWrapper.outputcCsgS)Nr)rrrr�error�szTransactionWrapper.errorcCs|jj�|k|_dS)N)rCrM�altered_gt_rpmdb)rZrpmdbvrrr�compare_rpmdbv�sz!TransactionWrapper.compare_rpmdbvN)r=r>r?�altered_lt_rpmdbrcrr@rFrGrHrIrJrLrNrSrTrVrZr[r\r]rUrYrbrdrrrrrB�s*rBc@sheZdZdd�Zdd�Zedd��Zdd�Zed	d
��Zedd��Z	ed
d��Z
edd��Zdd�ZdS)�MergedTransactionWrappercCstjj|j�|_dS)N)rPrQZMergedTransactionrC)rrDrrrr�sz!MergedTransactionWrapper.__init__cCs|jj|j�dS)N)rC�merge)rrDrrrrg�szMergedTransactionWrapper.mergecCs
|jj�S)N)rCZlistUserIds)rrrrrT�sz!MergedTransactionWrapper.loginuidcCs
|jj�S)N)rCZlistIds)rrrrr\szMergedTransactionWrapper.tidscCsdd�|jj�D�S)NcSsg|]}t|tjjk��qSr)rOrPrQrR)r^r_rrrr`sz8MergedTransactionWrapper.return_code.<locals>.<listcomp>)rCZ
listStates)rrrrrSsz$MergedTransactionWrapper.return_codecCs
|jj�S)N)rCZlistCmdlines)rrrrrGsz MergedTransactionWrapper.cmdlinecCs
|jj�S)N)rCZlistReleasevers)rrrrrHsz#MergedTransactionWrapper.releasevercCs
|jj�S)N)rCZlistComments)rrrrr[sz MergedTransactionWrapper.commentcCsdd�|jj�D�S)NcSsg|]}|d�qS)rr)r^r_rrrr`sz3MergedTransactionWrapper.output.<locals>.<listcomp>)rCrW)rrrrrYszMergedTransactionWrapper.outputN)
r=r>r?rrgr@rTr\rSrGrHr[rYrrrrrf�srfc@s�eZdZd6dd�Zdd�Zedd��Zedd	��Zed
d��Zedd
��Z	edd��Z
dd�Zdd�Zedd��Z
dd�Zd7dd�Zd8dd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd9d(d)�Zd*d+�Zd,d-�Zd:d.d/�Zd;d0d1�Zd2d3�Zd4d5�ZdS)<�
SwdbInterfacer,cCs8t|�|_d|_d|_d|_d|_d|_||_g|_dS)N)	�strrH�_rpm�_group�_envZ_addon_datar
�_db_dir�_output)rZdb_dirrHrrrrs
zSwdbInterface.__init__cCs|j�dS)N)�close)rrrr�__del__%szSwdbInterface.__del__cCs|jdkrt|�|_|jS)N)rjr)rrrrr8(s

zSwdbInterface.rpmcCs|jdkrt|�|_|jS)N)rkr)rrrr�group.s

zSwdbInterface.groupcCs|jdkrt|�|_|jS)N)rlr)rrrr�env4s

zSwdbInterface.envcCstjj|jtjjj�S)N)�os�path�joinrmrPrQ�SwdbZdefaultDatabaseName)rrrr�dbpath:szSwdbInterface.dbpathcCsZ|jsTytjj|j�|_Wn.tk
rH}ztt|���WYdd}~XnX|jj�|jS)z Lazy initialize Swdb object N)	r
rPrQrvrw�RuntimeErrorrri�initTransaction)rZexrrrr
>s
zSwdbInterface.swdbcCstjj||j�}|j�dS)N)rPrQZTransformerrw�	transform)rZ	input_dirZtransformerrrrrzKszSwdbInterface.transformcCsZy|`Wntk
rYnXd|_d|_d|_|jrJ|jj�|jj�d|_g|_dS)N)	�_tidr-rjrkrlr
ZcloseTransactionZ
closeDatabasern)rrrrroOs

zSwdbInterface.closecCs
|jj�S)N)r
ZgetPath)rrrrrt]szSwdbInterface.pathcCs
|jj�S)N)r
Z
resetDatabase)rrrr�reset_dbaszSwdbInterface.reset_dbTcCs|jj�}|sdSt|�S)N)r
ZgetLastTransactionrB)r�complete_transactions_only�trrr�lastes
zSwdbInterface.lastNrFcs��pg�dd��D��|jj�}dd�|D�}�rD�fdd�|D�}xJt|�D]>\}}|dkr`qN||d}|jj�|jj�krNd|_d|_qNW|ddd�S)	NcSsg|]}t|��qSr)rO)r^r_rrrr`osz%SwdbInterface.old.<locals>.<listcomp>cSsg|]}t|��qSr)rB)r^r_rrrr`qscsg|]}|j�kr|�qSr)rF)r^r_)r\rrr`tsrrT���)r
ZlistTransactions�	enumeraterCrKrMrerc)rr\�limitr}rar_rDZ
prev_transr)r\r�oldms

zSwdbInterface.oldcCst|jj��S)N)rBr
Z
getCurrent)rrrr�get_current�szSwdbInterface.get_currentcCsB|jj|�}|j|�}tjj}|jj||||�}|jtjj	�|S)zSet reason for package)
r8Z_pkg_to_swdb_rpm_item�reporPrQZ#TransactionItemAction_REASON_CHANGEr
ZaddItemr2rR)rr:r+�rpm_itemZrepoidr)Ztirrr�
set_reason�s
zSwdbInterface.set_reasoncCs|jjt|��S)zGet repository of package)r
Z
getRPMRepori)rr:rrrr��szSwdbInterface.repocCs*|jjt|��}|dkr|St||�}|S)zGet package data for packageN)r
ZgetRPMTransactionItemrir	)rr:rarrr�package_data�s

zSwdbInterface.package_datacCsfy|jj�WnYnX|jjttjtj���t|�|p>dtt	j
��|�}|jj|j�||_
|S)Nr,)r
ryZbeginTransactionrO�calendarZtimegm�timeZgmtimerirZgetloginuidZ
setReleaseverrHr{)rZ
rpmdb_versionZ
using_pkgsZtsisrGr[rFrrr�beg�s
zSwdbInterface.begcCsN|jj�}|j|j�|j|jp"d�|j|j�|j|j	�|j
|j�|S)Nr)r
Z
createRPMItemZsetNamer!ZsetEpochr"Z
setVersionr#Z
setReleaser$ZsetArchr%)rZpor�rrr�pkg_to_swdb_rpm_item�s
z"SwdbInterface.pkg_to_swdb_rpm_itemcCsDt|d�sdS|sdSx(|j�D]}t|�}|jjd|f�q WdS)Nr{r)�hasattr�
splitlinesrrn�append)r�msg�linerrr�log_scriptlet_output�s
z"SwdbInterface.log_scriptlet_outputcCs�t|d�sdS|dkrFtjj}x&|jD]}|jtjjkr&tjj}Pq&Wx |jD]\}}|j	j
||�qNWg|_|j	jtt
j
��t|�|�dS)Nr{)r�rPrQZTransactionState_DONEr8r1ZTransactionItemState_ERRORZTransactionState_ERRORrnr
ZaddConsoleOutputLineZendTransactionrOr�ri)rrNrS�errorsZtsiZfile_descriptorr�rrr�end�s

zSwdbInterface.endcCs|jj|�S)z{ Search for history transactions which contain specified
            packages al. la. "yum list". Returns transaction ids. )r
ZsearchTransactionsByRPM)rZpatternsZignore_caserrr�search�szSwdbInterface.searchcCs8|jj|j|jd�}|tjjkr$dS|tjjkr4dSdS)z)Returns True if package is user installedrTFr�)r
�resolveRPMTransactionItemReasonr!r%rPrQ�TransactionItemReason_USER�TransactionItemReason_UNKNOWN)rr:r+rrr�user_installed�szSwdbInterface.user_installedcCsF|r|jj|j|j|�}n|jj|j|jd�}|tjjkrBtjj}|S)a2Get reason of package before transaction being undone. If package
        is already installed in the system, keep his reason.

        :param pkg: package being installed
        :param first_trans: id of first transaction being undone
        :param rollback: True if transaction is performing a rollbackrr�)r
r�r!r%rPrQr�r�)rr:Zfirst_transZrollbackrarrr�get_erased_reason�szSwdbInterface.get_erased_reason)r,)T)NrF)Nr,)r,NN)T)r=r>r?rrpr@r8rqrrrwr
rzrortr|rr�r�r�r�r�r�r�r�r�r�r�r�rrrrrhs0




	

rh)r�rsr�Zlibdnf.transactionrPZlibdnf.utilsZdnf.i18nrZdnf.yumrZdnf.exceptionsrrqrrr�objectr	rBrfrhrrrr�<module>sM"

?>