diff --git a/influxdb/client.py b/influxdb/client.py index 1a7cbbdf..62d5a025 100644 --- a/influxdb/client.py +++ b/influxdb/client.py @@ -82,7 +82,6 @@ def __init__(self, """Construct a new InfluxDBClient object.""" self.__host = host self.__port = int(port) - self.__path = path if not path or path[0] == '/' else '/' + path self._username = username self._password = password self._database = database @@ -102,6 +101,13 @@ def __init__(self, if use_udp: self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + if not path: + self.__path = '' + elif path[0] == '/': + self.__path = path + else: + self.__path = '/' + path + self._scheme = "http" if ssl is True: diff --git a/influxdb/tests/client_test.py b/influxdb/tests/client_test.py index d35d0628..efdfb770 100644 --- a/influxdb/tests/client_test.py +++ b/influxdb/tests/client_test.py @@ -115,6 +115,12 @@ def test_scheme(self): ) self.assertEqual('https://host:8086/somepath', cli._baseurl) + cli = InfluxDBClient( + 'host', 8086, 'username', 'password', 'database', ssl=True, + path=None + ) + self.assertEqual('https://host:8086', cli._baseurl) + cli = InfluxDBClient( 'host', 8086, 'username', 'password', 'database', ssl=True, path="/somepath"