ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     3
g                 @   st  d Z ddlmZ ddlmZ ddlmZ yddlmZ W n  ek
rX   ddlmZ Y nX 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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m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!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(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/Zddl0Zddl1Zddl2Zddl3Zddl4Zddl5Zddl6Zddl7Zddl8Zddl9Z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@ZddlAZddlBZddlCZddlDZe
jEdZFdddZGdd ZHdd ZIdd ZJG dd dejKZLG dd deMZNdS )z/
Command line interface yum class and related.
    )print_function)absolute_import)unicode_literals)SequenceN   )output)CliError)ucd_dnf c             C   s   t |jd t |j t | }t |j}t |j}xFd|fd|fd|ffD ],\}}| | j|d | | |  d7  < qLW dS )zl Get the length of each pkg's column. Add that to data.
        This "knows" about simpleList and printVer. r   naverridr   N)lennamearchZevrZ
_from_repo
setdefault)datapkgindentr   r   r   dv r   /usr/lib/python3.6/cli.py_add_pkg_simple_list_lens]   s     

 r   c             C   s   i i i d}x<|j |j|j|j|j|jfD ]}x|D ]}t|| q4W q*W t|jdkrx*|j	D ] \}}t|| t||dd q`W |d |d |d g}| j
|d	d
}|d  |d	  |d  fS )zA Work out the dynamic size of the columns to pass to fmtColumns. )r   r   r   r       )r   r   r   r   r   )Zremainder_column   z    )	installed	availableextras
autoremoveupdatesrecentr   r   	obsoletesobsoletesTuplesZcalcColumns)r   yplr   Zlstr   ZnpkgZopkgcolumnsr   r   r   _list_cmd_calc_columnsh   s    

r)   c       	      C   s   dd }t jj|}d}x|j j j| dD ]}|r>td d}|jdkrbd|j|j	|j
f }nd	|j|j|j	|j
f }|jj|j}ttd
||||jf  ttd|jr|jnd||jf  q.W d S )Nc             S   s   t jdt j| S )Nz%c)timestrftimeZgmtime)xr   r   r   
sm_ui_timez   s    z"print_versions.<locals>.sm_ui_timeF)r   r   T0z%s-%s.%sz%s:%s-%s.%sz  Installed: %s-%s at %sz  Built    : %s at %s)r   sack
rpmdb_sackqueryr   filtermprintZepochversionreleaser   termboldr   r
   ZinstalltimeZpackagerZ	buildtime)	pkgsbaser   r-   r0   doner   r   r   r   r   r   print_versionsy   s     
r;   c             C   s>   t d}x0| j D ]$\}}tj|j||d |d  qW d S )NzTThe operation would result in switching of module '{0}' stream '{1}' to stream '{2}'r   r   )r
   itemsloggerwarningformat)switchedModulesZmsg1Z
moduleNameZstreamsr   r   r   report_module_switch   s    rA   c                   s   e Zd ZdZd  fdd	Zf f fdd	Zdd Zd	d
 Zdd Zdd Z	f dddfddZ
dd Zg g dfddZdf dfddZd!ddZ fddZdd Z  ZS )"BaseCliz#This is the base class for yum cli.Nc                s4   |pt jj }tt| j|d tj| | j| _d S )N)conf)r   rC   ZConfsuperrB   __init__r   ZOutput)selfrC   )	__class__r   r   rE      s    zBaseCli.__init__c                s  t jjrJ| jjsJt| jj }|rJt| t	dj
t jjd}t jj|| j}| jj|}|rjtj| |rg }g }d}xF|D ]>}	|	jt jjkr|j|	j q|	jt jjkrd}|j|	j qW | `|s| jj| n| jj|| |s| jj s| jr| jjs| jjr| jj r:tjt	dj
t jj!d n(d| jj"krbtjt	dj
t jj!d | j# r| jj$s| jj%  rt&t	dntjt	d	 d
S |rD|r:tjt	d y| jj'}
| j(|| jj)|
 W n\ t jj*k
r8 } z:t j+j
j,t-|}t	dd|  }t.  t jj|W Y d
d
}~X nX | j/| | jj rRd
S t0|t1sd|g}tj2 gt3| }t4t5| j6|}|d
k	r| j7j8|gd }t j9jj:| j7|j;}nd
}|rt.  t.dj<| jj=| t.  x.|D ]&}	|	j>t?jj@krt jjt	dqW |S )zTake care of package downloading, checking, user
        confirmation and actually running the transaction.

        :param display: `rpm.callback.TransactionProgress` object(s)
        :return: history database transaction ID or None
        aQ  It is not possible to switch enabled streams of a module unless explicitly enabled via configuration option module_stream_switch.
It is recommended to rather remove all installed content from the module, and reset the module using '{prog} module reset <module_name>' command. After you reset the module, you can install the other stream.)progTFz7{prog} will only download packages for the transaction.ZtestzP{prog} will only download packages, install gpg keys, and check the transaction.zOperation aborted.zNothing to do.NzDownloading Packages:zError downloading packages:z
%sr   
zTransaction failed)Ar   r9   ZWITH_MODULESrC   Zmodule_stream_switchdictZ_moduleContainerZgetSwitchedStreamsrA   r
   r?   util	MAIN_PROG
exceptionsErrorZtransactionr   Zlist_transactionr=   infoactionZFORWARD_ACTIONSappendr   ZBACKWARD_ACTIONSZ_tsZreportRemoveSizeZreportDownloadSizeZ	isChangedZ_historygroupenvdownloadonlyMAIN_PROG_UPPERZtsflags_promptWantedassumenouserconfirmr   Zdownload_callback_total_cbZdownload_packagesprogressZDownloadErrorcliZindent_blockr	   r3   gpgsigcheck
isinstancer   ZCliTransactionDisplaylistrD   rB   do_transactionhistoryoldZdbZRPMTransactionZ_transjoinZpost_transaction_outputstatelibdnfZTransactionItemState_ERROR)rF   Zdisplayr@   msgZtransZpkg_strZinstall_pkgsZrmpkgsZinstall_onlyZtsiZtotal_cbeZspecificZerrstrtid)rG   r   r   r^      s    







zBaseCli.do_transactionc       
         s  g }x|D ]} j |\}}|dkr(q
q
|dkrĈ jjo@ jj }tj sVtjj  rl| rltjj	t
d fdd}y j|| W q tjj	tfk
r } z|jt| W Y dd}~X qX q
|j| q
W |rx|D ]}	tj|	 qW tjj	t
ddS )a  Perform GPG signature verification on the given packages,
        installing keys if possible.

        :param pkgs: a list of package objects to verify the GPG
           signatures of
        :raises: Will raise :class:`Error` if there's a problem
        r   r   zTRefusing to automatically import keys when running unattended.
Use "-y" to override.c                s
    j j S )N)r   rX   )r,   yz)rF   r   r   <lambda>$  s    z%BaseCli.gpgsigcheck.<locals>.<lambda>NzGPG check FAILED)Z_sig_check_pkgrC   	assumeyesrW   sysstdinisattyr   rM   rN   r
   Z_get_key_for_package
ValueErrorrQ   strr=   critical)
rF   r8   Zerror_messagesporesulterrmsgZayfnre   rd   r   )rF   r   r[     s&    
"
zBaseCli.gpgsigcheckc                sX   d x:| j jjd|jD ]$}|tj }|rtjj|d  P qW  fdd|j	D }|S )zBReturn list of changelogs for package newer then installed versionNr   r   c                s$   g | ]} d ks|d  kr|qS )N	timestampr   ).0Zchlog)newestr   r   
<listcomp>=  s    z-BaseCli.latest_changelogs.<locals>.<listcomp>)
Z_rpmconnZreadonly_tsZdbMatchr   rpmZRPMTAG_CHANGELOGTIMEdatetimeZdateZfromtimestamp
changelogs)rF   packageZmiZchangelogtimesZchlogsr   )rw   r   latest_changelogs3  s    
zBaseCli.latest_changelogsc             C   s4   d|d j dtjj|d tjj|d f }|S )z*Return changelog formatted as in spec filez* %s %s
%s
ru   z%a %b %d %X %YZauthortext)r+   r   Zi18nr	   )rF   Z	changelogZ	chlog_strr   r   r   format_changelogA  s
    zBaseCli.format_changelogc             C   s   t  }x&|D ]}|j|jp|jg j| qW xdt|j D ]T}|| }ttdj	dj
dd |D  x$| j|d D ]}t| j| qzW q<W d S )NzChangelogs for {}z, c             S   s   g | ]}t |qS r   )ro   )rv   r   r   r   r   rx   Q  s    z,BaseCli.print_changelogs.<locals>.<listcomp>r   )rJ   r   source_namer   rQ   sortedkeysr3   r
   r?   ra   r}   r   )rF   ZpackagesZbysrpmpr   Zbin_packagesZchlr   r   r   print_changelogsI  s    
"zBaseCli.print_changelogsTFc          	   C   sR  | j d||d}| jjs | jjr@| j d||d}|j|_|j|_|rDt| j|}t|jdkri }| jj	j
d }	|	rx>t|jD ]0}
|
j }tjj|r|
j r|
||
j|
jf< qW | jj}| jj}| jj|jdd||||dd	 |r| j|j t|jdkrDttd
 x0t|jtjddD ]}| jj|d|d q(W |jpP|jS )z?Check updates matching given *patterns* in selected repository.Zupgrades)reponamer%   r   r7   r   r]   )=znot in)Z
outputTypehighlight_nar(   highlight_modeszObsoleting Packages)key)r(   )returnPkgListsrC   r%   verboser&   r)   r   r   r#   r6   MODEr   ZlocalPkgospathexistsZverifyLocalPkgr   r   color_update_localcolor_update_remotelistPkgsr   r3   r
   operator
itemgetterupdatesObsoletesList)rF   patternsr   Zprint_r{   r'   Ztyplr(   
local_pkgs	highlightrq   Zlocalculcurobtupr   r   r   check_updatesU  s:    
zBaseCli.check_updatesc             C   sr   | j j }t|dkr | j  nx|D ]}| j| q&W | j j | }|dkrn| j j  rntd}tjj|dS )ab   Upgrade or downgrade packages to match the latest versions available
            in the enabled repositories.

            :return: (exit_code, [ errors ])

            exit_code is::
                0 = we're done, exit
                1 = we've errored, exit with error string
                2 = we've got work yet to do, onto the next stage
        r   z4No packages marked for distribution synchronization.N)	Z_goalZ
req_lengthr   Zdistro_syncZreq_has_distupgrade_allr
   r   rM   rN   )rF   ZuserlistZoldcountpkg_specZcntrd   r   r   r   distro_sync_userlist{  s    


zBaseCli.distro_sync_userlistc       
      C   sT  d}xf|D ]^}y| j ||d d}W q
 tjjk
rf } z"tjtd| jjj	|j
 W Y dd}~X q
X q
W x|D ]}y| j||d d}W qr tjjk
r } z$td}	tj|	| jjj	| W Y dd}~X qr tjjk
r } z"tjtd| jjj	|j W Y dd}~X qr tjjk
r4   ds0tY qrX qrW |sPtjjtddS )	aa  Attempt to take the user specified list of packages or
        wildcards and downgrade them. If a complete version number is
        specified, attempt to downgrade them to the specified version

        :param specs: a list of names or wildcards specifying packages to downgrade
        :param file_pkgs: a list of pkg objects from local files
        F)strictTzNo match for argument: %sNzNo package %s available.z6Packages for argument %s available, but not installed.z!No packages marked for downgrade.)Zpackage_downgrader   rM   ZMarkingErrorr=   rO   r
   r   r6   r7   locationZdowngrade_toZPackageNotFoundErrorZPackagesNotInstalledErrorr   AssertionErrorrN   )
rF   ZspecsZ	file_pkgsr   rr   r   re   argerrrd   r   r   r   downgradePkgs  s,    	

(
&
"zBaseCli.downgradePkgsallc       !      C   sD  y$| j jjd }| j||||d}W n0 tjjk
rT } zdt|gfS d}~X nX i }i }	i }
d}|dkrzt| j |}|r|j	rxB|j
|j |j D ],}|j|jf}||ks||| kr|||< qW |o|jrx8|jD ].}|j|jf}||	ks||	| kr||	|< qW |rP|jrPx2t|jD ]$}|jtjkr(||
|j|jf< q(W | jj}| jj}| jj}| jj}| j j|j	td|||||||dd}| jj}| jj}| jj}| jj }| j j|jtd	||	|||||d
d}| j j|j!td||d}| j j|j"td||d}| jj#}| jj$}| j j|jtd||
|||dd}t%|j&dkr|dkrt%|j&}t'td xLt|j(t)j*ddD ]}| j j+|d|d qW n| j j|j&td||d}| j j|j,td||d} t%|r@| dkr@|dkr@|dkr@|dkr@|dkr@|dkr@|dkr@tjjtddS )zJOutput selection *pkgnarrow* of packages matching *patterns* and *repoid*.r7   )installed_availabler   r   Nr]   zInstalled Packages)><r   znot in)r   r(   r   zAvailable Packages)r   r   r   znot inzAutoremove Packages)r(   zExtra PackageszAvailable Upgrades)r   znot inr   zObsoleting Packages)r   r%   zRecently Added PackageszNo matching Packages to list)-r   r6   r   r   r   rM   rN   ro   r)   r   hidden_availablereinstall_availableZold_availabler   r   r    hidden_installedr#   r   r   hawkeyZSYSTEM_REPO_NAMErC   Zcolor_list_installed_olderZcolor_list_installed_newerZcolor_list_installed_reinstallZcolor_list_installed_extrar   r
   Zcolor_list_available_upgradeZcolor_list_available_downgradeZcolor_list_available_reinstallZcolor_list_available_installr"   r!   r   r   r   r%   r3   r&   r   r   r   r$   )!rF   basecmd	pkgnarrowr   r   r   r'   re   Zupdate_pkgsZ	inst_pkgsr   r(   r   r   rq   ZclioZclinZclirZclieZripZclauZcladZclarZclaiZrapZraepZrepr   r   ZrupZropr   Zrrapr   r   r   output_packages  s    







FzBaseCli.output_packagesc       	      C   s   d}d}|r|dkrd}d}n|r2|dkr2d}d}| j ||d|d}| jjrvx(|jD ]}|j rT| rT|jj| qTW |r|j|_|j|_|rg |_|rg |_|S )a#  Return a :class:`dnf.yum.misc.GenericHolder` object containing
        lists of package objects that match the given names or wildcards.

        :param pkgnarrow: a string specifying which types of packages
           lists to produce, such as updates, installed, available, etc.
        :param patterns: a list of names or wildcards specifying
           packages to list
        :param installed_available: whether the available package list
           is present as .hidden_available when doing all, available,
           or installed
        :param reponame: limit packages list to the given repository

        :return: a :class:`dnf.yum.misc.GenericHolder` instance with the
           following lists defined::

             available = list of packageObjects
             installed = list of packageObjects
             upgrades = tuples of packageObjects (updating, installed)
             extras = list of packageObjects
             obsoletes = tuples of packageObjects (obsoleting, installed)
             recent = list of packageObjects
        Fr   Tr   r    )Zignore_caser   )	Z_do_package_listsrC   showdupesfromreposr   r   r    rQ   r   r   )	rF   r   r   r   r   Zdone_hidden_availableZdone_hidden_installedr'   r   r   r   r   r     s,    zBaseCli.returnPkgListsc       	         s   | j j}d| j _g }g }x4|D ],}tt| j|\}}|j| |j| qW x t|D ]}| jj||| qXW || j _|st	j
jtddS )a  Print out a list of packages that provide the given file or
        feature.  This a cli wrapper to the provides methods in the
        rpmdb and pkgsack.

        :param args: the name of a file or feature to search for
        :return: (exit_code, [ errors ])

        exit_code is::

            0 = we're done, exit
            1 = we've errored, exit with error string
            2 = we've got work yet to do, onto the next stage
        TzNo Matches foundN)rC   r   rD   rB   providesextendr   r   Zmatchcallback_verboser   rM   rN   r
   )	rF   argsZold_sdupZmatchesZused_search_stringsspecr1   Zused_search_stringr   )rG   r   r   r   ?  s    

zBaseCli.providesc             C   s   | j jr| j j rdS dS )NFT)rC   rj   rW   )rF   r   r   r   rV   ^  s    zBaseCli._promptWanted)N)r   NFN)__name__
__module____qualname____doc__rE   r^   r[   r}   r   r   r   r   r   r   r   r   rV   __classcell__r   r   )rG   r   rB      s   k'&"Y 
1rB   c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdddZd ddZ	d!ddZ
d"ddZejfddZdd Zdd Zdd Zdd ZdS )#Clic             C   s"  || _ i | _d | _tjjj | _| jtjj	j
j | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	jj | jtjj	j j! | jtjj	j"j# | jtjj	j$j% | jtjj	j&j' | jtjj	j(j) | jtjj	j*j+ | jtjj	j,j- | jtjj	j.j/ | jtjj	j0j1 | jtjj	j2j3 | jtjj	j4j5 | jtjj	j6j7 | jtjj	j8 | jtjj	j9 | jtjj	j: | jtjj	j; | jtjj	j< | jtjj	j= d S )N)>r9   cli_commandscommandr   rZ   ZdemandZDemandSheetdemandsregister_commandZcommandsaliasZAliasCommandr"   ZAutoremoveCommandZcheckZCheckCommandZcleanZCleanCommandZ
distrosyncZDistroSyncCommandZdeplistZDeplistCommandZ	downgradeZDowngradeCommandrR   ZGroupCommandr_   ZHistoryCommandZinstallZInstallCommandZ	makecacheZMakeCacheCommandZmarkZMarkCommandmoduleZModuleCommandZ	reinstallZReinstallCommandremoveZRemoveCommandrepolistZRepoListCommandZ	repoqueryZRepoQueryCommandsearchZSearchCommandshellZShellCommandZswapZSwapCommandZ
updateinfoZUpdateInfoCommandZupgradeZUpgradeCommandZupgrademinimalZUpgradeMinimalCommandZInfoCommandZListCommandZProvidesCommandZCheckUpdateCommandZRepoPkgsCommandZHelpCommand)rF   r9   r   r   r   rE   f  sB    zCli.__init__c             C   s  | j j| |jr^xJ|jj D ]<\}}| j jj|| j j|gd}|j| |jj	|df qW |j
r|jjdd |jjdd |j
D  t }yzxt|jD ]j\}}| j jj|}|s| j jjr|dkrtd}	tjj|	| |j| |dk r|j  q|j  qW W nF tjjk
rP }
 z$tj|
 | jj  tjd	 W Y d d }
~
X nX x|D ]}tjtd
| qXW | j jj  }|d kr| j jj! }x,|D ]$}| j jj"|}|r|j#j$  qW | j j%j& \}| j _'| j jj( j)| t%j*| j | j j%}| j jj( j+| d S )N)Zbaseurlenabler   *disablec             S   s   g | ]}|d fqS )r   r   )rv   rr   r   r   rx     s    z(Cli._configure_repos.<locals>.<listcomp>zUnknown repo: '%s'r   zNo repository match: %s)r   r   ),r9   Zread_all_reposZrepofrompathr<   reposZadd_new_reporC   _configure_from_optionsZrepos_edrQ   repoinsertr   setZget_matchingr   r
   r   rM   Z	RepoErroraddr   r   ConfigErrorr=   rp   	optparser
print_helprk   exitr>   Z_repo_persistorZget_expired_reposr   get_repoexpirer   Zsetup_progress_callbacksZ_ds_callbackr   set_progress_barZCliKeyImportZ_set_key_import)rF   optsZlabelr   Z	this_repoZnotmatchr   Z	operationr   rd   re   Zexpired_reposr   ZbarZ
key_importr   r   r   _configure_repos  sL    








zCli._configure_reposc             C   sv   t jdjtjjdtjj t jtj	j
d| j t jtj	j
d| jjj t jtj	j
d| jjj t jd| jjj d S )Nz{prog} version: %s)rH   zCommand: %szInstallroot: %szReleasever: %szcachedir: %s)r=   debugr?   r   rK   rU   constVERSIONlogloggingDDEBUG	cmdstringr9   rC   installroot
releasevercachedir)rF   r   r   r   _log_essentials  s    



zCli._log_essentialsc             C   s  | j }| jj}|jr.tjj s.tjjt	d|j
rLx|j D ]
}d|_q>W |js\| jjjrd| jj_xn|j D ]}|jjtjj qpW nL|jrxD|j D ]}|jj  qW n(|jsx |j D ]}|jjtjj qW |j r| jj| j jrdnd| j jd d S )Nz[This command has to be run with superuser privileges (under the root user on most systems).TautoF)load_system_repoZload_available_repos)r   r9   r   Z	root_userr   rK   Z	am_i_rootrM   rN   r
   r{   iter_enabledZload_metadata_other	cacheonlyrC   valuesr   ZsetSyncStrategyr   ZSYNC_ONLY_CACHEfreshest_metadatar   Zfresh_metadataZ	SYNC_LAZYZsack_activationZ	fill_sackr   Zavailable_repos)rF   r   r   r   r   r   r   _process_demands  s.    



zCli._process_demandsc             C   s   |j }| jj|}|dkr~tjtd|tjd  | jj	j
r`tjtdjtjjtjjd| ntjtdjtjjd t|| | _ tjtjjd| tjtjjd	| dS )
z,Check that the requested CLI command exists.Nz)No such command: %s. Please use %s --helpr   zLIt could be a {PROG} plugin command, try: "{prog} install 'dnf-command(%s)'")rH   ZPROGzRIt could be a {prog} plugin command, but loading of plugins is currently disabled.)rH   zBase command: %szExtra commands: %s)r   r   r   r=   rp   r
   rk   argvr9   rC   Zpluginsr?   r   rK   rL   rU   r   r   r   r   )rF   r   r   r   command_clsr   r   r   _parse_commands  s    


zCli._parse_commandsNc       	      C   s  t jjj }|j|}|dkr*t jjj n|| _| jj|}|j	rpt
t jj t| jjj| j| jj tjd |jrd|_d|_|jrt jj |_|_yh|jr| jjjd| jjjt jj d| j_| jjj| | j|j  d|kr|j!| jj_!| jjj"  W n t j#j$t%fk
rF } z t&j't(d| tjd W Y dd}~X nX t)k
r } z:d	t*t+|t,|j-f }t&j't(d| tjd W Y dd}~X nX |j.dk	r|j.| jj_.| jjj/ r|j0dkrt&j't(d tjd |j1s|j2r|j0dkrt&j't(d tjd |j3dk	r>t4j5t6j7|j3d  | jj8| j9d | jj:|j;|j<|  | jj8| j9d |j0s| jj=  tjd || j_>| jj?d | _@x$| jj>D ]}|  j@d| 7  _@qW | jA  y| jB|| W n  tCk
r   tjd Y nX |jDr$| jj=| j0 tjd | jjE| j0|}|jFrN|jF| j_Gd| j_H|jIr`|jI| j_I|jJrrd| jj_K|jLrd| jj_L| j0jM  | jjN  | jjO  | jP| | jjQ  | jjj| | j0jR  | jjj.r t jSjT| jjj. | jjj.| jjUjV _W| jjjXdkr(| jjjYjZ| jjjXd t[j\ddkrd}x,| jjUj] D ]}|j^rZqJd|_^d}qJW | jjj_sd| jj__d}|rt&j`t(d dS )a  Parse command line arguments, and set up :attr:`self.base.conf` and
        :attr:`self.cmds`, as well as logger objects in base instance.

        :param args: a list of command line arguments
        :param option_parser: a class for parsing cli options
        Nr   r   r   Tr   zConfig error: %sr   z%s: %sdownloadsystem-upgradereposync
modulesynczb--destdir or --downloaddir must be used with --downloadonly or download or system-upgrade command.zconfig-managerz_--enable, --set-enabled and --disable, --set-disabled must be used with config-manager command.<   mainZpluginr   z%s r   )colorz%_pkgverify_level	signaturer   FzWarning: Enforcing GPG signature check globally as per active RPM security policy (see 'gpgcheck' in dnf.conf(5) for how to squelch this message))r   r   r   r   )r   r   )ar   rZ   aliasesZAliasesZresolveoption_parserZOptionParserr   Zparse_main_argsr4   r3   r   r   r;   r9   rC   Zhistory_record_packagesr   rk   r   quietZ
debuglevelZ
errorlevelr   ZVERBOSE_LEVELr   Z
_set_valueZsystem_cachedirZPRIO_DEFAULTr   r   _read_conf_filer   r   Z_adjust_conf_optionsrM   r   rn   r=   rp   r
   IOErrorr	   ro   reprfilenameZdestdirrT   r   Zset_enabledZset_disabledZ	sleeptimer*   ZsleeprandomZ	randrangeZadd_commandsr   Zinit_pluginsZdisablepluginZenablepluginr   r   rH   r   r   r   r   helpZparse_command_argsZallowerasingZallow_erasingZ_allow_erasingr   ZdebugsolverZdebug_solverr%   Zpre_configureZpre_configure_pluginsZ_activate_persistorr   Zconfigure_plugins	configurerK   Z
ensure_dirr   r   Zpkgdirr   r6   Zreinitry   ZexpandMacror   ZgpgcheckZlocalpkg_gpgcheckr>   )	rF   r   r   r   r   re   r   Zforcingr   r   r   r   r     s    





















zCli.configurec             C   sB  t jjd}| jj}|jd |jd |jd}|jdt jj	krht
jj| rht jjtdj||jt jjd |jd}|jdt jj	krd}|j}|j||jdd |d kr|jd krt jj|j}n|dkrt jj|}|d k	r||_|jd krtjtd	 xdD ]}|j| qW | jjj| |  |S )NconfigZconfig_file_pathzConfig file "{}" does not exist)ZpriorityZreposdirvarsdir/)r  zPUnable to detect release version (use '--releasever' to specify release version)r   logdir
persistdir)r   r  r  )r   r   ZTimerr9   rC   Z_check_remote_fileZ_search_inside_installrootZ
_get_valueZ_get_priorityZPRIO_COMMANDLINEr   r   isfilerM   r   r
   r?   readZPRIO_MAINCONFIGZsubstitutionsZupdate_from_etcr   ry   Zdetect_releaseverr   r=   r>   Zprepend_installroot_loggingZ_setup_from_dnf_conf)rF   r   ZtimerrC   r   Z	from_rootZsubstoptr   r   r   r     s6    




zCli._read_conf_fileeqc             C   s   |dkr|dkrdS g }|j s"|r,|jd |js6|r@|jd |jsJ|rT|jd |js^|rh|jd | jj|||j|j|j	|j
d dS )zz

        :param opts:
        :param cmp_type: string supported "eq", "gte"
        :param all:
        :return:
        Nbugfixenhancement
newpackagesecurity)typesadvisorybugzillacvesseverity)r
  rQ   r  r  r  r9   Zadd_security_filtersr  r  r  r  )rF   r   Zcmp_typer   r  r   r   r    _populate_update_security_filter  s    







z$Cli._populate_update_security_filterc             C   s4   |dk	r| j jjj| |dk	r0| j jjj| dS )z
        Change minimal logger level for terminal output to stdout and stderr according to specific
        command requirements
        @param stdout: logging.INFO, logging.WARNING, ...
        @param stderr:logging.INFO, logging.WARNING, ...
        N)r9   r  Zstdout_handlerZsetLevelZstderr_handler)rF   stdoutstderrr   r   r   redirect_logger  s    zCli.redirect_loggerc             C   s.   t jjj|}|| jj_| jjj j| d S )N)	r   rZ   rY   ZMultiFileProgressMeterr9   r   r   r   r   )rF   ZforY   r   r   r   redirect_repo_progress  s    
zCli.redirect_repo_progressc             C   s   | j jj }|d krd S | j jj j|jd}|j }|jdd |}x|D ]}||krL|}qLW ||krtd|  td|  d S )N)r   r  )Zadvisory_typez,Security: %s is an installed security updatez-Security: %s is the currently running version)r9   r/   Zget_running_kernelr1   r2   r   r   r3   )rF   ZkernelqZikpkgr   r   r   r   _check_running_kernel  s    
zCli._check_running_kernelc             C   s*   t | jj  tjjtdj||d S )Nz)argument {}: not allowed with argument {})r3   r   Zprint_usager   rM   rN   r
   r?   )rF   Zoption_string_1Zoption_string_2r   r   r   _option_conflict  s    zCli._option_conflictc             C   s<   x6|j D ],}|| jkr*tjjtd| || j|< qW dS )zRegister a Command. :apizCommand "%s" already definedN)r   r   r   rM   r   r
   )rF   r   r   r   r   r   r     s    
zCli.register_commandc             C   s   | j   | jjjr8tjtddjtt	| jjj  | jjj
rhtjtddjtt	| jjj
  xx| jjj D ]h}|jrtjtd|j d djtt	|j  |j
rvtjtd|j d djtt	|j
  qvW | jj S )a2  Call the base command, and pass it the extended commands or
           arguments.

        :return: (exit_code, [ errors ])

        exit_code is::

            0 = we're done, exit
            1 = we've errored, exit with error string
            2 = we've got work yet to do, onto the next stage
        zExcludes in dnf.conf: z, zIncludes in dnf.conf: zExcludes in repo z: zIncludes in repo )r   r9   rC   Zexcludepkgsr=   r   r
   ra   r   r   Zincludepkgsr   r   idr   run)rF   r   r   r   r   r    s    
"
"(,zCli.run)N)N)r	  N)NN)r   r   r   rE   r   r   r   r   r   r   r  r  rk   r  r  r  r  r   r  r   r   r   r   r   e  s   $3
 
-

r   )r   )Or   Z
__future__r   r   r   collections.abcr   ImportErrorcollectionsrz   r   r   r   r   ry   rk   r*   r   Zlibdnf.transactionrc   r   r   Zdnf.clir   Zdnf.i18nr	   r
   r   Zdnf.cli.aliasesZdnf.cli.commandsZdnf.cli.commands.aliasZdnf.cli.commands.autoremoveZdnf.cli.commands.checkZdnf.cli.commands.cleanZdnf.cli.commands.deplistZdnf.cli.commands.distrosyncZdnf.cli.commands.downgradeZdnf.cli.commands.groupZdnf.cli.commands.historyZdnf.cli.commands.installZdnf.cli.commands.makecacheZdnf.cli.commands.markZdnf.cli.commands.moduleZdnf.cli.commands.reinstallZdnf.cli.commands.removeZdnf.cli.commands.repolistZdnf.cli.commands.repoqueryZdnf.cli.commands.searchZdnf.cli.commands.shellZdnf.cli.commands.swapZdnf.cli.commands.updateinfoZdnf.cli.commands.upgradeZdnf.cli.commands.upgrademinimalZdnf.cli.demandZdnf.cli.formatZdnf.cli.option_parserZdnf.confZdnf.conf.substitutionsZ	dnf.constZdnf.db.historyZdnf.exceptionsZdnf.loggingZdnf.persistorZ
dnf.pluginZdnf.rpmZdnf.sackZdnf.transactionZdnf.utilZdnf.yum.miscZ	getLoggerr=   r   r)   r;   rA   ZBaserB   objectr   r   r   r   r   <module>   s   

   O