Don't try to resolve server version for old hubs

Related: https://pagure.io/koji/issue/3890
This commit is contained in:
Tomas Kopecek 2023-09-05 12:38:58 +02:00
parent d43ad529c1
commit 7a9b0561eb
7 changed files with 69 additions and 21 deletions

View file

@ -324,9 +324,8 @@ def handle_add_channel(goptions, session, args):
if 'channel %s already exists' % channel_name in msg:
error("channel %s already exists" % channel_name)
elif 'Invalid method:' in msg:
version = session.getKojiVersion()
error("addChannel is available on hub from Koji 1.26 version, your version is %s" %
version)
session.hub_version_str)
else:
error(msg)
print("%s added: id %d" % (args[0], channel_id))
@ -356,9 +355,8 @@ def handle_edit_channel(goptions, session, args):
except koji.GenericError as ex:
msg = str(ex)
if 'Invalid method:' in msg:
version = session.getKojiVersion()
error("editChannel is available on hub from Koji 1.26 version, your version is %s" %
version)
session.hub_version_str)
else:
warn(msg)
if not result:
@ -6295,14 +6293,6 @@ def handle_cancel(goptions, session, args):
if len(args) == 0:
parser.error("You must specify at least one task id or build")
activate_session(session, goptions)
older_hub = False
try:
hub_version = session.getKojiVersion()
v = tuple([int(x) for x in hub_version.split('.')])
if v < (1, 33, 0):
older_hub = True
except koji.GenericError:
older_hub = True
tlist = []
blist = []
for arg in args:
@ -6329,7 +6319,7 @@ def handle_cancel(goptions, session, args):
for task_id in tlist:
results.append(remote_fn(task_id, **opts))
for build in blist:
if not older_hub:
if session.hub_version >= (1, 33, 0):
results.append(m.cancelBuild(build, strict=True))
else:
results.append(m.cancelBuild(build))