From 65ae5867babff33140a1ec0298c0337bdc3917e7 Mon Sep 17 00:00:00 2001 From: Yuguang Wang Date: Tue, 2 Apr 2024 11:03:45 +0800 Subject: [PATCH] client: catch exception when hub connection fails Related: https://issues.redhat.com/browse/OSH-144 --- kobo/client/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kobo/client/__init__.py b/kobo/client/__init__.py index c929e5f..00f69a8 100644 --- a/kobo/client/__init__.py +++ b/kobo/client/__init__.py @@ -73,6 +73,7 @@ def run(self, *args, **kwargs): import base64 import hashlib import ssl +import sys import warnings import six.moves.urllib.parse as urlparse from six.moves import xmlrpc_client as xmlrpclib @@ -111,7 +112,11 @@ def set_hub(self, username=None, password=None, hub=None): if hub: self.conf["HUB_URL"] = hub - self.hub = HubProxy(conf=self.conf) + try: + self.hub = HubProxy(conf=self.conf) + except Exception as ex: + print(f"Failed to initialize hub proxy: {ex}", file=sys.stderr) + sys.exit(1) class ClientCommandContainer(BaseClientCommandContainer):