3 ©ft`]ã@slddlmZddlmZddlmZddlmZddlmZddl Z ddl Z e j dƒZ Gdd „d ejƒZdS) é)Úabsolute_import)Úunicode_literals)Úcommands)Ú OptionParser)Ú_NÚdnfc@s8eZdZdZd ZedƒZedd„ƒZdd„Z d d „Z d S) ÚReinstallCommandzSA class containing methods needed by the cli to execute the reinstall command. Ú reinstallÚreizreinstall a packagecCs"|jddtdƒtjtdƒd�dS)NÚpackagesú+zPackage to reinstallZPACKAGE)ÚnargsÚhelpÚactionÚmetavar)Ú add_argumentrrZParseSpecGroupFileCallback)Úparser©rú/usr/lib/python3.6/reinstall.pyÚ set_argparser(szReinstallCommand.set_argparsercCsH|jj}d|_d|_d|_d|_tj|j|jƒ|j j sDtj |jƒdS)a Verify that conditions are met so that this command can run. These include that the program is being run by the root user, that there are enabled repositories with gpg keys, and that this command is called with appropriate arguments. TN) ZcliÚdemandsZsack_activationZavailable_reposZ resolvingZ root_userrZ _checkGPGKeyÚbaseÚoptsÚ filenamesZ_checkEnabledRepo)ÚselfrrrrÚ configure.szReinstallCommand.configurecCsæd}xp|jj|jjd|jjjd�D]P}y|jj|ƒWn6tjj k rlt j t dƒ|jjj j|jƒƒYq"Xd}q"W�xR|jjdd„|jjDƒD�]2}y|jj|ƒW�ntjjk �r}zPx,|jD]"}t j t dƒ|jj j|jƒƒPqÌWt j t dƒ|jjj j|ƒƒWYdd}~Xq”tjjk �rœ}z^xV|jD]L}d}|jjj|ƒ}|�rdt d ƒ|}t d ƒ}t j ||jjj j|ƒ|ƒ�qLsz(ReinstallCommand.run..z(Package %s available, but not installed.Úz (from %s)z%Installed package %s%s not available.z+Only the above marking errors are expected.z!No packages marked for reinstall.)rZadd_remote_rpmsrrÚoutputrZpackage_reinstallrÚ exceptionsZ MarkingErrorÚloggerÚinforZtermZboldÚlocationZ pkg_specsZ grp_specsr ZPackagesNotInstalledErrorr ÚnameZPackagesNotAvailableErrorÚhistoryZrepoÚAssertionErrorÚError)rÚdoneZpkgZpkg_specÚerrZxmsgZpkgrepoÚmsgrrrÚrun=sB $   "  zReinstallCommand.runN)r r ) Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚaliasesrZsummaryÚ staticmethodrrr/rrrrr!s  r)Z __future__rrZdnf.clirZdnf.cli.option_parserrZdnf.i18nrZdnf.exceptionsrZloggingZ getLoggerr%ZCommandrrrrrÚs