3 ©ft`~ã@stddlmZddlmZddlZddlZddlZddlmZddl m Z ddl m Z ej dƒZGdd „d ejƒZdS) é)Úabsolute_import)Úunicode_literalsN)Úcommands)Ú OptionParser)Ú_Údnfc@sXeZdZdZdZedƒZed d „ƒZd d „Z d d„Z dd„Z dd„Z dd„Z dd„ZdS)ÚUpgradeCommandzTA class containing methods needed by the cli to execute the update command. ÚupgradeÚupdateú upgrade-toú update-toÚ localupdateÚupz,upgrade a package or packages on your systemcCs"|jddtdƒtjtdƒd�dS)NZpackagesÚ*zPackage to upgradeZPACKAGE)ÚnargsÚhelpÚactionÚmetavar)Ú add_argumentrrZParseSpecGroupFileCallback)Úparser©rú/usr/lib/python3.6/upgrade.pyÚ set_argparser*szUpgradeCommand.set_argparsercCsZ|jj}d|_d|_d|_d|_tj|j|jƒ|j j sDtj |jƒd|_ d|_ d|_dS)zÌVerify that conditions are met so that this command can run. These include that there are enabled repositories with gpg keys, and that this command is being run by the root user. TN)ÚcliÚdemandsZsack_activationZavailable_reposZ resolvingZ root_userrZ _checkGPGKeyÚbaseÚoptsÚ filenamesZ_checkEnabledRepoÚupgrade_minimalÚ all_securityÚskipped_grp_specs)ÚselfrrrrÚ configure0s zUpgradeCommand.configurecCsœ|jr dnd}|jj|j||jd�|jjs<|jjs<|jjrzd}||jƒO}||j ƒO}||j ƒO}||j ƒO}|rˆdSn|j j ƒdStjjtdƒƒ‚dS)NÚeqZgte)Úcmp_typeÚallFzNo packages marked for upgrade.)rrZ _populate_update_security_filterrrrÚ pkg_specsÚ grp_specsÚ_update_modulesÚ _update_filesÚ_update_packagesÚ_update_groupsrZ upgrade_allrÚ exceptionsÚErrorr)r!r$ÚresultrrrÚrunBs       zUpgradeCommand.runcCsNt|jjƒ}tjjr6tjjj|jƒ}|j |jjƒ|_ n |jj|_ t|j ƒ|kS)N) Úlenrr'rrZ WITH_MODULESÚmoduleÚ module_baseZ ModuleBaser r )r!Zgroup_specs_numr2rrrr(Vs   zUpgradeCommand._update_modulescCs�d}|jjrŒx~|jj|jjd|jjjd�D]^}y|jj|ƒd}Wq*tjj k r†}z$t j t dƒ|jjj j|jƒƒWYdd}~Xq*Xq*W|S)NF)ÚstrictÚprogressTzNo match for argument: %s)rrrZadd_remote_rpmsÚoutputr4Zpackage_upgraderr,Ú MarkingErrorÚloggerÚinforÚtermÚboldÚlocation)r!ÚsuccessZpkgÚerrrr)`s  *zUpgradeCommand._update_filescCsrd}xh|jjD]\}y|jj|ƒd}Wqtjjk rh}z"tjt dƒ|jj j j |ƒƒWYdd}~XqXqW|S)NFTzNo match for argument: %s) rr&rr rr,r6r7r8rr5r9r:)r!r<Zpkg_specr=rrrr*ms  (zUpgradeCommand._update_packagescCs|jr|jj|jƒdSdS)NTF)r rZenv_group_upgrade)r!rrrr+xszUpgradeCommand._update_groupsN)r r r r r r)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚaliasesrZsummaryÚ staticmethodrr"r/r(r)r*r+rrrrr#s    r)Z __future__rrZloggingZdnf.exceptionsrZdnf.baseZdnf.clirZdnf.cli.option_parserrZdnf.i18nrZ getLoggerr7ZCommandrrrrrÚs