AlkantarClanX12

Your IP : 3.144.82.128


Current Path : /proc/self/root/lib/python3.6/site-packages/dnf/yum/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/dnf/yum/__pycache__/rpmtrans.cpython-36.pyc

3

�ft`�>�	@sHddlmZmZddlmZddlZddlmZmZddl	Z
ddlZ
ddlZ
ddl
Z
ddlZddlZddlZddlZddlZddlZdZdZdZdZd	Zd
ZdZdZeeegZeeegZejjejj ejj!ejj"ejj#ejj$ejj%ejj&ejj'h	Z(ej)d
�Z*dd�Z+Gdd�de,�Z-Gdd�de-�Z.Gdd�de-�Z/Gdd�de,�Z0dS)�)�print_function�absolute_import)�unicode_literalsN)�_�ucd�
��(�2�<�F�Z�d�dnfcst�fdd��}|S)zb
    Wrapper to return a deprecated action constant
    while printing a deprecation warning.
    cs2d|jj��f}tj|tdd�ttj��}|S)Nz1%s.%s is deprecated. Use dnf.callback.%s instead.�)�
stacklevel)�	__class__�__name__�warnings�warn�DeprecationWarning�getattrr�callback)�self�msg�value)�name��/usr/lib/python3.6/rpmtrans.py�_funcCs
z%_add_deprecated_action.<locals>._func)�property)rrr)rr�_add_deprecated_action>sr!c@s�eZdZdd�Zed�Zed�Zed�ZeZed�Z	ed�Z
ed�Zed	�Zed
�Z
ed�Zed�Zed
�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)�TransactionDisplaycCsdS)Nr)rrrr�__init__PszTransactionDisplay.__init__�PKG_CLEANUP�
PKG_DOWNGRADE�
PKG_REMOVE�PKG_INSTALL�PKG_OBSOLETE�
PKG_REINSTALL�PKG_UPGRADE�
PKG_VERIFY�TRANS_PREPARATION�
PKG_SCRIPTLET�
TRANS_POSTcCsdS)aReport ongoing progress on a transaction item. :api

        :param package: a package being processed
        :param action: the action being performed
        :param ti_done: number of processed bytes of the transaction
           item being processed
        :param ti_total: total number of bytes of the transaction item
           being processed
        :param ts_done: number of actions processed in the whole
           transaction
        :param ts_total: total number of actions in the whole
           transaction

        Nr)r�package�actionZti_doneZti_totalZts_doneZts_totalrrr�progressbszTransactionDisplay.progresscCsdS)z_Hook for reporting an rpm scriptlet output.

        :param msgs: the scriptlet output
        Nr)r�msgsrrr�	scriptoutsszTransactionDisplay.scriptoutcCsdS)z:Report an error that occurred during the transaction. :apiNr)r�messagerrr�errorzszTransactionDisplay.errorcCsdS)z|package is the same as in progress() - a package object or simple
           string action is also the same as in progress()Nr)rr/r0rrr�filelog~szTransactionDisplay.filelogcCs|j|tjjdd||�dS)Nr)r1r�transactionr+)r�pkg�count�totalrrr�verify_tsi_package�sz%TransactionDisplay.verify_tsi_packageN)r�
__module__�__qualname__r#r!r$r%r&Z	PKG_ERASEr'r(r)r*r+r,r-r.r1r3r5r6r;rrrrr"Ms$r"cs eZdZdZ�fdd�Z�ZS)�ErrorTransactionDisplayz@An RPMTransaction display that prints errors to standard output.cs&tt|�j|�tjjd|tj�dS)N�print)�superr>r5r�utilZ_terminal_messenger�sys�stderr)rr4)rrrr5�szErrorTransactionDisplay.error)rr<r=�__doc__r5�
__classcell__rr)rrr>�sr>cs8eZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�ZS)
�LoggingTransactionDisplayz@
    Base class for a RPMTransaction display callback class
    cstt|�j�tjd�|_dS)Nzdnf.rpm)r@rFr#�logging�	getLogger�
rpm_logger)r)rrrr#�sz"LoggingTransactionDisplay.__init__cCs|jj|�dS)N)rIr5)rr4rrrr5�szLoggingTransactionDisplay.errorcCs.tjj|}d||f}|jjtjj|�dS)Nz%s: %s)rr7ZFILE_ACTIONSrI�logrGZSUBDEBUG)rr/r0Z
action_strrrrrr6�sz!LoggingTransactionDisplay.filelogcCs|r|jjt|��dS)N)rI�infor)rr2rrrr3�sz#LoggingTransactionDisplay.scriptout)	rr<r=rDr#r5r6r3rErr)rrrF�s
rFc@s�eZdZdffdd�Zd8dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7S)9�RPMTransactionFcCsn|st�g}||_||_||_d|_d|_d|_d|_d|_t	�|_
d|_|j|j
j�g|_d|_d|_dS)NFr)r>�displays�base�test�
trans_running�fd�
total_actions�total_installed�complete_actions�set�installed_pkg_names�
total_removed�_setupOutputLoggingZconf�rpmverbosity�_te_list�	_te_index�
_tsi_cache)rrNrOrMrrrr#�s zRPMTransaction.__init__rKcCs~tj�}||_t|jd�|_|jjj|j�dddddd�j	||�}d|j
�}tt|�s^d	}tj
tt|��tj|j�dS)
Nzw+bZcritZemerg�errrKZwarning)�criticalZ	emergencyr5ZinformationrZRPMLOG_ZRPMLOG_INFO)�tempfileZNamedTemporaryFile�	_readpipe�openr�
_writepiperN�_tsZsetScriptFd�get�upper�hasattr�rpm�setVerbosityr�
setLogFile)rrYZio_rrrrrX�s
z"RPMTransaction._setupOutputLoggingc	Cs8tjtj�tjtj�y|jj�WnYnXdS)N)rgrhZ
RPMLOG_NOTICErirBrCrb�close)rrrr�_shutdownOutputLogging�sz%RPMTransaction._shutdownOutputLoggingcCsBy(|jj|jj��|jj�}|s&dS|Stk
r<YnXdS)N)r`�seek�tell�read�IOError)r�outrrr�
_scriptOutput�s
zRPMTransaction._scriptOutputccs,|j�}|r(x|j�D]}t|�VqWdS)N)rq�
splitlinesr)r�messages�linerrrrs�szRPMTransaction.messagescCs4|j�}x|jD]}|j|�qW|jjj|�dS)N)rqrMr3rN�historyZlog_scriptlet_output)rr2�displayrrr�
_scriptout�szRPMTransaction._scriptoutcCs|j�dS)N)rk)rrrr�__del__�szRPMTransaction.__del__cCs�t|d�r|}|gS|j|j}tjj|�}|jrJt|jd�|krJ|jSg}x2|jj	D]&}|j
tkrhqXt|�|krX|j|�qXW|r�||_|St
d|��dS)z3Obtain the package related to the calling callback.r8rz%TransactionItem not found for key: %sN)rfrZr[rrAZ	_te_nevrar\�strrNr7r0�RPM_ACTIONS_SET�append�RuntimeError)rZcbkeyZtsiZteZte_nevra�itemsrrr�_extract_cbkey�s$

zRPMTransaction._extract_cbkeyc
Cs��y�t|t�rt|�}|tjkr.|j|��nv|tjkr<�nh|tjkrV|j||��nN|tj	krp|j
||��n4|tjkr�|j|�S|tj
kr�|j|��n|tjkr�|j|�n�|tjkr�|j|�n�|tjkr�|j|||�n�|tjkr�|j|�n�|tjk�r|j|�n�|tjk�r,|j|||�nx|tjk�rD|j|�n`|tjk�r\|j|�nH|tjk�rx|j |||�n,|tj!k�r�|j"|�n|tj#k�r�|j$�WnBt%k
�r�t&j'�\}}}t(j)|||�}	t*j+dj,|	��YnXdS)N�)-�
isinstanceryrrgZRPMCALLBACK_TRANS_START�_transStartZRPMCALLBACK_TRANS_STOPZRPMCALLBACK_TRANS_PROGRESS�_trans_progressZRPMCALLBACK_ELEM_PROGRESS�
_elemProgressZRPMCALLBACK_INST_OPEN_FILE�
_instOpenFileZRPMCALLBACK_INST_CLOSE_FILE�_instCloseFileZRPMCALLBACK_INST_START�_inst_startZRPMCALLBACK_INST_STOP�
_inst_stopZRPMCALLBACK_INST_PROGRESS�
_instProgressZRPMCALLBACK_UNINST_START�
_uninst_startZRPMCALLBACK_UNINST_STOP�_unInstStopZRPMCALLBACK_UNINST_PROGRESS�_uninst_progressZRPMCALLBACK_CPIO_ERROR�
_cpioErrorZRPMCALLBACK_UNPACK_ERROR�_unpackErrorZRPMCALLBACK_SCRIPT_ERROR�_scriptErrorZRPMCALLBACK_SCRIPT_START�
_script_startZRPMCALLBACK_SCRIPT_STOP�_scriptStop�	ExceptionrB�exc_info�	traceback�format_exception�loggerr^�join)
rZwhat�amountr:�keyZclient_data�exc_type�	exc_value�
exc_tracebackZexcept_listrrrrsR











zRPMTransaction.callbackcCs(||_|jrdSd|_t|jj�|_dS)NT)rRrOrP�listrNrcrZ)rr:rrrr�<s
zRPMTransaction._transStartcCs4tjj}x&|jD]}|jd||d|dd�qWdS)Nr�)rr7r,rMr1)rr�r:r0rvrrrr�BszRPMTransaction._trans_progresscCsP||_|jd7_|jsL|j|�}x&|jD]}|j|dj|dj�q,WdS)Nr�r)r[rTrOr~rMr6r8r0)rr��index�transaction_listrvrrrr�Gs
zRPMTransaction._elemProgresscCs�d|_|j|�}|dj}|j�}yt|�|_WnDtk
rt}z(x |jD]}|jd||f�qJWWYdd}~Xn.X|j	r�|j
d7_
|jj|j
�|jj�SdS)NrzError: Cannot open file %s: %sr�)Zlastmsgr~r8ZlocalPkgrarQrorMr5rPrSrV�addr�fileno)rr�r�r8Zrpmloc�ervrrrr�Os

(zRPMTransaction._instOpenFilecCs|jj�d|_dS)N)rQrj)rr�rrrr�_s
zRPMTransaction._instCloseFilecCsdS)Nr)rr�rrrr�cszRPMTransaction._inst_startcCsV|js|jrdS|j�|j|jkrRtjj}x"|jD]}|j	d|dddd�q6WdS)N)
rOrPrwrTrRrr7r.rMr1)rr�r0rvrrrr�fszRPMTransaction._inst_stopcCsJ|j|�}|dj}|dj}x&|jD]}|j|||||j|j�q&WdS)Nr)r~r8r0rMr1rTrR)rr�r:r�r�r8r0rvrrrr�rs



zRPMTransaction._instProgresscCs|jd7_dS)Nr�)rW)rr�rrrr�yszRPMTransaction._uninst_startcCsJ|j|�}|dj}|dj}x&|jD]}|j|||||j|j�q&WdS)Nr)r~r8r0rMr1rTrR)rr�r:r�r�r8r0rvrrrr�|s



zRPMTransaction._uninst_progresscCs|jr
dS|j�dS)N)rOrw)rr�rrrr��szRPMTransaction._unInstStopcCs6|j|�}d|dj}x|jD]}|j|�q WdS)Nz'Error in cpio payload of rpm package %sr)r~r8rMr5)rr�r�rrvrrrr��s
zRPMTransaction._cpioErrorcCs6|j|�}d|dj}x|jD]}|j|�q WdS)NzError unpacking rpm package %sr)r~r8rMr5)rr�r�rrvrrrr��s
zRPMTransaction._unpackErrorc	CsNtjj|d�}|j|�}|djj}d||f}x|jD]}|j|�q8WdS)Nz	<unknown>rz'Error in %s scriptlet in rpm package %s)rgZtagnamesrdr~r8rrMr5)	rr�r:r�Zscriptlet_namer�rrrvrrrr��s
zRPMTransaction._scriptErrorcCs�tjj}|dkr |jgkr d}n|j|�}|dj}|jdkrN|jdkrN|jnd}|jdkrl|jdkrl|jnd}x"|jD]}|j	||dd||�qxWdS)N�Nonerr�r)
rr7r-rZr~r8rRrTrMr1)rr�r0r8r�Zcompleter:rvrrrr��s

zRPMTransaction._script_startcCs|j�dS)N)rw)rrrrr��szRPMTransaction._scriptStopcCs"x|jD]}|j|||�qWdS)N)rMr;)rr8r9r:rvrrrr;�sz!RPMTransaction.verify_tsi_packageN)rK)rr<r=r#rXrkrqrsrwrxr~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r;rrrrrL�s4
	.
rL)1Z
__future__rrrZlibdnf.transactionZlibdnfZdnf.i18nrrZdnf.callbackrZdnf.transactionZdnf.utilrg�osrGrBr_r�rZ	TS_UPDATEZ
TS_INSTALLZTS_ERASEZTS_OBSOLETEDZ
TS_OBSOLETINGZTS_AVAILABLEZ
TS_UPDATEDZ	TS_FAILEDZTS_INSTALL_STATESZTS_REMOVE_STATESr7ZTransactionItemAction_INSTALLZTransactionItemAction_DOWNGRADEZ TransactionItemAction_DOWNGRADEDZTransactionItemAction_OBSOLETEZTransactionItemAction_OBSOLETEDZTransactionItemAction_UPGRADEZTransactionItemAction_UPGRADEDZTransactionItemAction_REMOVEZ!TransactionItemAction_REINSTALLEDrzrHr�r!�objectr"r>rFrLrrrr�<module>sL



<