3 ft`~ @ st d dl mZ d dl mZ d dlZd dlZd dlZd dlmZ d dl m Z d dlmZ ej dZG dd d ejZdS ) )absolute_import)unicode_literalsN)commands)OptionParser)_dnfc @ sX e Zd ZdZdZedZed d Zdd Z d d Z dd Zdd Zdd Z dd ZdS )UpgradeCommandzTA class containing methods needed by the cli to execute the update command. upgradeupdate upgrade-to update-tolocalupdateupz,upgrade a package or packages on your systemc C s" | j ddtdtjtdd d S )NZpackages*zPackage to upgradeZPACKAGE)nargshelpactionmetavar)add_argumentr r ZParseSpecGroupFileCallback)parser r /usr/lib/python3.6/upgrade.py set_argparser* s zUpgradeCommand.set_argparserc C sZ | j j}d|_d|_d|_d|_tj| j| j | j j sDtj| j d| _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_userr Z_checkGPGKeybaseopts filenamesZ_checkEnabledRepoupgrade_minimalall_securityskipped_grp_specs)selfr r r r configure0 s zUpgradeCommand.configurec C s | j r dnd}| jj| j|| jd | jjs<| jjs<| jjrzd}|| j O }|| j O }|| j O }|| j O }|rd S n| jj d S tjjtdd S )NeqZgte)cmp_typeallFzNo packages marked for upgrade.)r r Z _populate_update_security_filterr r r pkg_specs grp_specs_update_modules _update_files_update_packages_update_groupsr Zupgrade_allr exceptionsErrorr )r! r$ resultr r r runB s zUpgradeCommand.runc C sN t | jj}tjjr6tjjj| j}|j | jj| _ n | jj| _ t | j |kS )N)lenr r' r r ZWITH_MODULESmodulemodule_baseZ ModuleBaser r )r! Zgroup_specs_numr2 r r r r( V s zUpgradeCommand._update_modulesc C s d}| j jrx~| jj| j jd| jjjdD ]^}y| jj| d}W q* tjj k r } z$t jtd| jjj j|j W Y d d }~X q*X q*W |S )NF)strictprogressTzNo match for argument: %s)r r r Zadd_remote_rpmsoutputr4 Zpackage_upgrader r, MarkingErrorloggerinfor termboldlocation)r! successZpkger r r r) ` s *zUpgradeCommand._update_filesc C sr d}xh| j jD ]\}y| jj| d}W q tjjk rh } z"tjt d| jj jj| W Y d d }~X qX qW |S )NFTzNo match for argument: %s) r r&