From 52d44a1769d83ae30f6b3b0d99df68e5ff2f23cd Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jul 21 2020 20:42:20 +0000 Subject: [PATCH 1/2] cli: list-tags: fall back to old behavior on ParameterError Fixes https://pagure.io/koji/issue/2379 --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index a144938..019d33c 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -4116,15 +4116,27 @@ def anon_handle_list_tags(goptions, session, args): if not args: # list everything if no pattern is supplied - args = [None] + tags = session.listTags(build=buildinfo.get('id', None), + package=pkginfo.get('id', None)) + else: + # The hub may not support the pattern option. We try with that first + # and fall back to the old way. + fallback=False + try: + tags = [] + with session.multicall(strict=True) as m: + for arg in args: + tags.append(m.listTags(build=buildinfo.get('id', None), + package=pkginfo.get('id', None), + pattern=arg)) + tags = list(itertools.chain(*[t.result for t in tags])) + except koji.ParameterError: + fallback=True + if fallback: + # without the pattern option, we have to filter client side + tags = session.listTags(buildinfo.get('id', None), pkginfo.get('id', None)) + tags = [t for t in tags if koji.util.multi_fnmatch(t['name'], args)] - tags = [] - with session.multicall() as m: - for arg in args: - tags.append(m.listTags(build=buildinfo.get('id', None), - package=pkginfo.get('id', None), - pattern=arg)) - tags = list(itertools.chain(*[t.result for t in tags])) tags.sort(key=lambda x: x['name']) # if options.verbose: # fmt = "%(name)s [%(id)i] %(perm)s %(locked)s %(arches)s" From 8d715a44056ad2b4922ffa66ef9f9d61a7b51c36 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Jul 22 2020 14:15:11 +0000 Subject: [PATCH 2/2] whitespace to make flake8 happy --- diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index 019d33c..3eae261 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -4121,7 +4121,7 @@ def anon_handle_list_tags(goptions, session, args): else: # The hub may not support the pattern option. We try with that first # and fall back to the old way. - fallback=False + fallback = False try: tags = [] with session.multicall(strict=True) as m: @@ -4131,7 +4131,7 @@ def anon_handle_list_tags(goptions, session, args): pattern=arg)) tags = list(itertools.chain(*[t.result for t in tags])) except koji.ParameterError: - fallback=True + fallback = True if fallback: # without the pattern option, we have to filter client side tags = session.listTags(buildinfo.get('id', None), pkginfo.get('id', None))