error function instead of print with sys.exit in CLI commands

Fixes: https://pagure.io/koji/issue/3112
This commit is contained in:
Jana Cupova 2021-11-08 12:31:17 +01:00 committed by Tomas Kopecek
parent 6fd7845be3
commit 5232ea5aa1
3 changed files with 90 additions and 139 deletions

View file

@ -465,8 +465,7 @@ def handle_add_pkg(goptions, session, args):
# check if list of packages exists for that tag already
dsttag = session.getTag(tag)
if dsttag is None:
print("No such tag: %s" % tag)
sys.exit(1)
error("No such tag: %s" % tag)
try:
pkglist = session.listPackages(tagID=dsttag['id'], with_owners=False)
except koji.ParameterError:
@ -1451,8 +1450,7 @@ def handle_import_cg(goptions, session, args):
activate_session(session, goptions)
metadata = koji.load_json(args[0])
if 'output' not in metadata:
print("Metadata contains no output")
sys.exit(1)
error("Metadata contains no output")
localdir = args[1]
to_upload = []