3 ft`~@stddlmZddlmZddlZddlZddlZddlmZddl m Z ddl m Z ej dZGdd d ejZdS) )absolute_import)unicode_literalsN)commands) OptionParser)_dnfc@sXeZdZdZdZedZed d Zd d Z d dZ ddZ ddZ ddZ ddZdS)UpgradeCommandzTA class containing methods needed by the cli to execute the update command. upgradeupdate upgrade-to update-to localupdateupz,upgrade a package or packages on your systemcCs"|jddtdtjtdddS)NZpackages*zPackage to upgradeZPACKAGE)nargshelpactionmetavar) add_argumentrrZParseSpecGroupFileCallback)parserr/usr/lib/python3.6/upgrade.py set_argparser*szUpgradeCommand.set_argparsercCsZ|jj}d|_d|_d|_d|_tj|j|j|j j sDtj |jd|_ d|_ d|_dS)zVerify 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)clidemandsZsack_activationZavailable_reposZ resolvingZ root_userrZ _checkGPGKeybaseopts filenamesZ_checkEnabledRepoupgrade_minimal all_securityskipped_grp_specs)selfrrrr configure0s zUpgradeCommand.configurecCs|jr dnd}|jj|j||jd|jjs<|jjs<|jjrzd}||jO}||j O}||j O}||j O}|rdSn|j j dStjjtddS)NeqZgte)cmp_typeallFzNo packages marked for upgrade.)rrZ _populate_update_security_filterrrr pkg_specs grp_specs_update_modules _update_files_update_packages_update_groupsrZ upgrade_allr exceptionsErrorr)r!r$resultrrrrunBs       zUpgradeCommand.runcCsNt|jj}tjjr6tjjj|j}|j |jj|_ n |jj|_ t|j |kS)N) lenrr'rrZ WITH_MODULESmodule module_baseZ ModuleBaser r )r!Zgroup_specs_numr2rrrr(Vs   zUpgradeCommand._update_modulescCsd}|jjrx~|jj|jjd|jjjdD]^}y|jj|d}Wq*tjj k r}z$t j t d|jjj j|jWYdd}~Xq*Xq*W|S)NF)strictprogressTzNo match for argument: %s)rrrZadd_remote_rpmsoutputr4Zpackage_upgraderr, MarkingErrorloggerinfortermboldlocation)r!successZpkgerrrr)`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|jdSdS)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 getLoggerr7ZCommandrrrrrs