Skip to content

Commit b8f18d5

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 a4bd041 commit b8f18d5

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
@@ -14,7 +14,7 @@
1414
Examples:
1515
uv run koji-helper.py list v8.3-ci
1616
uv run koji-helper.py list-update v8.3-ci v8.3-updates
17-
uv run koji-helper.py --no-verify-ssl list-update v8.3-ci \
17+
uv run koji-helper.py list-update v8.3-ci \
1818
v8.3-testing v8.3-candidates v8.3-updates v8.3-base
1919
2020
@@ -48,10 +48,10 @@ class PackageInfo(TypedDict):
4848

4949
def get_session(args: argparse.Namespace) -> koji.ClientSession:
5050
"""Create and return a Koji client session."""
51-
session = koji.ClientSession(
52-
args.server,
53-
opts={"no_ssl_verify": args.no_verify_ssl},
54-
)
51+
# Open a koji session
52+
config = koji.read_config("koji")
53+
session = koji.ClientSession(args.server, config)
54+
session.ssl_login(config['cert'], None, config['serverca'])
5555
return session
5656

5757

@@ -202,12 +202,6 @@ def main() -> None:
202202
default="https://kojihub.xcp-ng.org",
203203
help="Koji hub server URL (default: %(default)s)",
204204
)
205-
parser.add_argument(
206-
"--no-verify-ssl",
207-
action="store_true",
208-
help="Ignore SSL certificate verification errors",
209-
)
210-
211205
subparsers = parser.add_subparsers(dest="command")
212206

213207
# list command
@@ -233,15 +227,10 @@ def main() -> None:
233227

234228
session = get_session(args)
235229

236-
try:
237-
if args.command == "list":
238-
do_list(session, args)
239-
elif args.command == "list-update":
240-
do_list_update(session, args)
241-
except Exception as e:
242-
print(f"Error: {e}", file=sys.stderr)
243-
sys.exit(1)
244-
230+
if args.command == "list":
231+
do_list(session, args)
232+
elif args.command == "list-update":
233+
do_list_update(session, args)
245234

246235
if __name__ == "__main__":
247236
main()

0 commit comments

Comments
 (0)