diff options
author | biao716.wang <biao716.wang@samsung.com> | 2022-08-02 19:18:29 +0900 |
---|---|---|
committer | biao716.wang <biao716.wang@samsung.com> | 2022-08-04 15:42:15 +0900 |
commit | f8781453269db52ea28bfdfe1de3f60e03db1370 (patch) | |
tree | 1a1002baa5e22cd70ef5b9eaed997968b7911806 /yumcommands.py | |
parent | 29ec9f8128e658bc1883c2c99ce43b2d550a90ee (diff) | |
download | yum-f8781453269db52ea28bfdfe1de3f60e03db1370.tar.gz yum-f8781453269db52ea28bfdfe1de3f60e03db1370.tar.bz2 yum-f8781453269db52ea28bfdfe1de3f60e03db1370.zip |
port code from python2.x to python3.x
Change-Id: Icc21ea029e40d82919e522f0ab5e99cc7a397399
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
Diffstat (limited to 'yumcommands.py')
-rw-r--r-- | yumcommands.py | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/yumcommands.py b/yumcommands.py index 4dcbea7..7205d62 100644 --- a/yumcommands.py +++ b/yumcommands.py @@ -212,7 +212,7 @@ class InstallCommand(YumCommand): self.doneCommand(base, _("Setting up Install Process")) try: return base.installPkgs(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] class UpdateCommand(YumCommand): @@ -234,7 +234,7 @@ class UpdateCommand(YumCommand): self.doneCommand(base, _("Setting up Update Process")) try: return base.updatePkgs(extcmds, update_to=(basecmd == 'update-to')) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] class DistroSyncCommand(YumCommand): @@ -257,7 +257,7 @@ class DistroSyncCommand(YumCommand): try: base.conf.obsoletes = 1 return base.distroSyncPkgs(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] def _add_pkg_simple_list_lens(data, pkg, indent=''): @@ -302,7 +302,7 @@ class InfoCommand(YumCommand): try: highlight = base.term.MODE['bold'] ypl = base.returnPkgLists(extcmds, installed_available=highlight) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] else: update_pkgs = {} @@ -369,7 +369,7 @@ class InfoCommand(YumCommand): if len(ypl.obsoletes) > 0 and basecmd == 'list': # if we've looked up obsolete lists and it's a list request rop = [0, ''] - print _('Obsoleting Packages') + print((_('Obsoleting Packages'))) # The tuple is (newPkg, oldPkg) ... so sort by new for obtup in sorted(ypl.obsoletesTuples, key=operator.itemgetter(0)): @@ -421,7 +421,7 @@ class EraseCommand(YumCommand): self.doneCommand(base, _("Setting up Remove Process")) try: return base.erasePkgs(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] def needTs(self, base, basecmd, extcmds): @@ -442,7 +442,7 @@ class GroupsCommand(YumCommand): 'groupinfo' : 'info'} def getNames(self): - return ['groups', 'group'] + self.direct_commands.keys() + return ['groups', 'group'] + list(self.direct_commands.keys()) def getUsage(self): return "[list|info|summary|install|upgrade|remove|mark] [GROUP]" @@ -458,7 +458,7 @@ class GroupsCommand(YumCommand): base.doGroupSetup() except yum.Errors.GroupsError: return 1, [_('No Groups on which to run command')] - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] def _grp_cmd(self, basecmd, extcmds): @@ -524,7 +524,7 @@ class GroupsCommand(YumCommand): if cmd == 'remove': return base.removeGroups(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] @@ -577,7 +577,7 @@ class MakeCacheCommand(YumCommand): base.repos.populateSack(mdtype='otherdata', cacheonly=1) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] return 0, [_('Metadata Cache Created')] @@ -623,7 +623,7 @@ class ProvidesCommand(YumCommand): base.logger.debug("Searching Packages: ") try: return base.provides(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] class CheckUpdateCommand(YumCommand): @@ -668,14 +668,14 @@ class CheckUpdateCommand(YumCommand): highlight_modes={'=' : cul, 'not in' : cur}) result = 100 if len(ypl.obsoletes) > 0: # This only happens in verbose mode - print _('Obsoleting Packages') + print((_('Obsoleting Packages'))) # The tuple is (newPkg, oldPkg) ... so sort by new for obtup in sorted(ypl.obsoletesTuples, key=operator.itemgetter(0)): base.updatesObsoletesList(obtup, 'obsoletes', columns=columns) result = 100 - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] else: return result, [] @@ -697,7 +697,7 @@ class SearchCommand(YumCommand): base.logger.debug(_("Searching Packages: ")) try: return base.search(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] def needTs(self, base, basecmd, extcmds): @@ -723,7 +723,7 @@ class UpgradeCommand(YumCommand): self.doneCommand(base, _("Setting up Upgrade Process")) try: return base.updatePkgs(extcmds, update_to=(basecmd == 'upgrade-to')) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] class LocalInstallCommand(YumCommand): @@ -751,7 +751,7 @@ class LocalInstallCommand(YumCommand): updateonly = basecmd == 'localupdate' try: return base.localInstall(filelist=extcmds, updateonly=updateonly) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] def needTs(self, base, basecmd, extcmds): @@ -771,7 +771,7 @@ class ResolveDepCommand(YumCommand): base.logger.debug(_("Searching Packages for Dependency:")) try: return base.resolveDepCli(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] class ShellCommand(YumCommand): @@ -791,7 +791,7 @@ class ShellCommand(YumCommand): self.doneCommand(base, _('Setting up Yum Shell')) try: return base.doShell() - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] def needTs(self, base, basecmd, extcmds): @@ -815,7 +815,7 @@ class DepListCommand(YumCommand): self.doneCommand(base, _("Finding dependencies: ")) try: return base.deplist(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] @@ -855,7 +855,7 @@ class RepoListCommand(YumCommand): extcmds = extcmds[1:] else: arg = 'enabled' - extcmds = map(lambda x: x.lower(), extcmds) + extcmds = [x.lower() for x in extcmds] verbose = base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3) if arg != 'disabled' or extcmds: @@ -867,7 +867,7 @@ class RepoListCommand(YumCommand): if verbose: raise - repos = base.repos.repos.values() + repos = list(base.repos.repos.values()) repos.sort() enabled_repos = base.repos.listEnabled() on_ehibeg = base.term.FG_COLOR['green'] + base.term.MODE['bold'] @@ -1173,7 +1173,7 @@ class ReInstallCommand(YumCommand): try: return base.reinstallPkgs(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [to_unicode(e)] def getSummary(self): @@ -1199,7 +1199,7 @@ class DowngradeCommand(YumCommand): self.doneCommand(base, _("Setting up Downgrade Process")) try: return base.downgradePkgs(extcmds) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] def getSummary(self): @@ -1256,9 +1256,9 @@ class VersionCommand(YumCommand): groups[group].update(base.run_with_package_names) if vcmd == 'grouplist': - print _(" Yum version groups:") + print((_(" Yum version groups:"))) for group in sorted(groups): - print " ", group + print((" ", group)) return 0, ['version grouplist'] @@ -1266,11 +1266,11 @@ class VersionCommand(YumCommand): for group in groups: if group not in extcmds[1:]: continue - print _(" Group :"), group - print _(" Packages:") + print((_(" Group :"), group)) + print((_(" Packages:"))) if not verbose: for pkgname in sorted(groups[group]): - print " ", pkgname + print((" ", pkgname)) else: data = {'envra' : {}, 'rid' : {}} pkg_names = groups[group] @@ -1307,7 +1307,7 @@ class VersionCommand(YumCommand): cols.append(("%s %s" % (_("Group-Installed:"), grp), str(data[2][grp]))) _append_repos(cols, data[3][grp]) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] if vcmd in ('available', 'all', 'group-available', 'group-all'): try: @@ -1326,7 +1326,7 @@ class VersionCommand(YumCommand): str(data[2][grp]))) if verbose: _append_repos(cols, data[3][grp]) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [str(e)] data = {'rid' : {}, 'ver' : {}} @@ -1339,7 +1339,7 @@ class VersionCommand(YumCommand): columns = (-columns[0], columns[1]) for line in cols: - print base.fmtColumns(zip(line, columns)) + print((base.fmtColumns(list(zip(line, columns))))) return 0, ['version'] @@ -1368,7 +1368,7 @@ class HistoryCommand(YumCommand): if old is None: return 1, ['Failed history redo'] tm = time.ctime(old.beg_timestamp) - print "Repeating transaction %u, from %s" % (old.tid, tm) + print(("Repeating transaction %u, from %s" % (old.tid, tm))) base.historyInfoCmdPkgsAltered(old) if base.history_redo(old): return 2, ["Repeating transaction %u" % (old.tid,)] @@ -1378,7 +1378,7 @@ class HistoryCommand(YumCommand): if old is None: return 1, ['Failed history undo'] tm = time.ctime(old.beg_timestamp) - print "Undoing transaction %u, from %s" % (old.tid, tm) + print(("Undoing transaction %u, from %s" % (old.tid, tm))) base.historyInfoCmdPkgsAltered(old) if base.history_undo(old): return 2, ["Undoing transaction %u" % (old.tid,)] @@ -1400,14 +1400,14 @@ class HistoryCommand(YumCommand): return 0, ['Rollback to current, nothing to do'] mobj = None - for tid in base.history.old(range(old.tid + 1, last.tid + 1)): + for tid in base.history.old(list(range(old.tid + 1, last.tid + 1))): if not force and (tid.altered_lt_rpmdb or tid.altered_gt_rpmdb): if tid.altered_lt_rpmdb: msg = "Transaction history is incomplete, before %u." else: msg = "Transaction history is incomplete, after %u." - print msg % tid.tid - print " You can use 'history rollback force', to try anyway." + print((msg % tid.tid)) + print(" You can use 'history rollback force', to try anyway.") return 1, ['Failed history rollback, incomplete'] if mobj is None: @@ -1416,9 +1416,9 @@ class HistoryCommand(YumCommand): mobj.merge(tid) tm = time.ctime(old.beg_timestamp) - print "Rollback to transaction %u, from %s" % (old.tid, tm) - print base.fmtKeyValFill(" Undoing the following transactions: ", - ", ".join((str(x) for x in mobj.tid))) + print(("Rollback to transaction %u, from %s" % (old.tid, tm))) + print((base.fmtKeyValFill(" Undoing the following transactions: ", + ", ".join((str(x) for x in mobj.tid))))) base.historyInfoCmdPkgsAltered(mobj) if base.history_undo(mobj): return 2, ["Rollback to transaction %u" % (old.tid,)] @@ -1496,7 +1496,7 @@ class CheckRpmdbCommand(YumCommand): chkcmd = extcmds def _out(x): - print to_unicode(x.__str__()) + print((to_unicode(x.__str__()))) rc = 0 if base._rpmdb_warn_checks(out=_out, warn=False, chkcmd=chkcmd, @@ -1527,7 +1527,7 @@ class LoadTransactionCommand(YumCommand): try: base.load_ts(load_file) - except yum.Errors.YumBaseError, e: + except yum.Errors.YumBaseError as e: return 1, [to_unicode(e)] return 2, [_('Transaction loaded from %s with %s members') % (load_file, len(base.tsInfo.getMembers()))] |