Fix client init to work with URL and (host,port) 25/14425/2
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 17 Jun 2024 10:12:35 +0000 (12:12 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 17 Jun 2024 10:26:46 +0000 (12:26 +0200)
Change-Id: I8a04b7d46bcd6b7706e109058c217962a092c80f
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osmclient/sol005/client.py

index fe72850..a106c49 100644 (file)
@@ -65,16 +65,14 @@ class Client(object):
         self._token = None
         self._url = None
         if host.startswith("http://") or host.startswith("https://"):
-            self._url = self._host
+            self._url = host
         else:
-            if len(host.split(":")) > 1:
+            host_fields = host.split(":")
+            if len(host_fields) > 1:
                 # backwards compatible, port provided as part of host
-                self._host = host.split(":")[0]
-                self._so_port = host.split(":")[1]
-            else:
-                self._host = host
-                self._so_port = so_port
-            self._url = "https://{}:{}/osm".format(self._host, self._so_port)
+                host = host_fields[0]
+                so_port = host_fields[1]
+            self._url = "https://{}:{}/osm".format(host, so_port)
         self._http_client = http.Http(self._url, **kwargs)
         self._headers["Accept"] = "application/json"
         self._headers["Content-Type"] = "application/yaml"