Skip to content

Commit 51a766d

Browse files
committed
s/koji-helper.py: Refactor session to handle local koji conf
Signed-off-by: Philippe Coval <philippe.coval@vates.tech>
1 parent 271aa4a commit 51a766d

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

‎scripts/koji/koji-helper.py‎

100644100755
Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Examples:
1212
uv run koji-helper.py list v8.3-ci
1313
uv run koji-helper.py list-update v8.3-ci v8.3-updates
14-
uv run koji-helper.py --no-verify-ssl list-update v8.3-ci \
14+
uv run koji-helper.py list-update v8.3-ci \
1515
v8.3-testing v8.3-candidates v8.3-updates v8.3-base
1616
1717
@@ -45,10 +45,10 @@ class PackageInfo(TypedDict):
4545

4646
def get_session(args: argparse.Namespace) -> koji.ClientSession:
4747
"""Create and return a Koji client session."""
48-
session = koji.ClientSession(
49-
args.server,
50-
opts={"no_ssl_verify": args.no_verify_ssl},
51-
)
48+
# Open a koji session
49+
config = koji.read_config("koji")
50+
session = koji.ClientSession(args.server, config)
51+
session.ssl_login(config['cert'], None, config['serverca'])
5252
return session
5353

5454

@@ -199,12 +199,6 @@ def main() -> None:
199199
default="https://kojihub.xcp-ng.org",
200200
help="Koji hub server URL (default: %(default)s)",
201201
)
202-
parser.add_argument(
203-
"--no-verify-ssl",
204-
action="store_true",
205-
help="Ignore SSL certificate verification errors",
206-
)
207-
208202
subparsers = parser.add_subparsers(dest="command")
209203

210204
# list command
@@ -230,15 +224,10 @@ def main() -> None:
230224

231225
session = get_session(args)
232226

233-
try:
234-
if args.command == "list":
235-
do_list(session, args)
236-
elif args.command == "list-update":
237-
do_list_update(session, args)
238-
except Exception as e:
239-
print(f"Error: {e}", file=sys.stderr)
240-
sys.exit(1)
241-
227+
if args.command == "list":
228+
do_list(session, args)
229+
elif args.command == "list-update":
230+
do_list_update(session, args)
242231

243232
if __name__ == "__main__":
244233
main()

0 commit comments

Comments
 (0)