Skip to content

Commit 678e5ed

Browse files
authored
Merge branch 'master' into dataframeclient_chunked_queries
2 parents 6d77010 + d8907d3 commit 678e5ed

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

influxdb/client.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def __init__(self,
9191

9292
self._verify_ssl = verify_ssl
9393

94-
self.use_udp = use_udp
95-
self.udp_port = udp_port
94+
self.__use_udp = use_udp
95+
self.__udp_port = udp_port
9696
self._session = requests.Session()
9797
if use_udp:
9898
self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -129,6 +129,14 @@ def _host(self):
129129
def _port(self):
130130
return self.__port
131131

132+
@property
133+
def _udp_port(self):
134+
return self.__udp_port
135+
136+
@property
137+
def _use_udp(self):
138+
return self.__use_udp
139+
132140
@classmethod
133141
def from_dsn(cls, dsn, **kwargs):
134142
r"""Generate an instance of InfluxDBClient from given data source name.
@@ -467,7 +475,7 @@ def _write_points(self,
467475
"Invalid time precision is given. "
468476
"(use 'n', 'u', 'ms', 's', 'm' or 'h')")
469477

470-
if self.use_udp and time_precision and time_precision != 's':
478+
if self._use_udp and time_precision and time_precision != 's':
471479
raise ValueError(
472480
"InfluxDB only supports seconds precision for udp writes"
473481
)
@@ -492,7 +500,7 @@ def _write_points(self,
492500
if retention_policy is not None:
493501
params['rp'] = retention_policy
494502

495-
if self.use_udp:
503+
if self._use_udp:
496504
self.send_packet(data, protocol=protocol)
497505
else:
498506
self.write(
@@ -821,7 +829,7 @@ def send_packet(self, packet, protocol='json'):
821829
data = make_lines(packet).encode('utf-8')
822830
elif protocol == 'line':
823831
data = ('\n'.join(packet) + '\n').encode('utf-8')
824-
self.udp_socket.sendto(data, (self._host, self.udp_port))
832+
self.udp_socket.sendto(data, (self._host, self._udp_port))
825833

826834
def close(self):
827835
"""Close http session."""

influxdb/influxdb08/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def __init__(self,
9292

9393
self._verify_ssl = verify_ssl
9494

95-
self.use_udp = use_udp
96-
self.udp_port = udp_port
95+
self._use_udp = use_udp
96+
self._udp_port = udp_port
9797
if use_udp:
9898
self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
9999

@@ -344,7 +344,7 @@ def _write_points(self, data, time_precision):
344344
raise Exception(
345345
"Invalid time precision is given. (use 's', 'm', 'ms' or 'u')")
346346

347-
if self.use_udp and time_precision != 's':
347+
if self._use_udp and time_precision != 's':
348348
raise Exception(
349349
"InfluxDB only supports seconds precision for udp writes"
350350
)
@@ -355,7 +355,7 @@ def _write_points(self, data, time_precision):
355355
'time_precision': time_precision
356356
}
357357

358-
if self.use_udp:
358+
if self._use_udp:
359359
self.send_packet(data)
360360
else:
361361
self.request(
@@ -849,4 +849,4 @@ def send_packet(self, packet):
849849
"""Send a UDP packet along the wire."""
850850
data = json.dumps(packet)
851851
byte = data.encode('utf-8')
852-
self.udp_socket.sendto(byte, (self._host, self.udp_port))
852+
self.udp_socket.sendto(byte, (self._host, self._udp_port))

influxdb/line_protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def quote_literal(value):
7575
def _is_float(value):
7676
try:
7777
float(value)
78-
except ValueError:
78+
except (TypeError, ValueError):
7979
return False
8080

8181
return True

influxdb/tests/client_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ def test_dsn(self):
119119
self.assertEqual('uSr', cli._username)
120120
self.assertEqual('pWd', cli._password)
121121
self.assertEqual('db', cli._database)
122-
self.assertFalse(cli.use_udp)
122+
self.assertFalse(cli._use_udp)
123123

124124
cli = InfluxDBClient.from_dsn('udp+' + self.dsn_string)
125-
self.assertTrue(cli.use_udp)
125+
self.assertTrue(cli._use_udp)
126126

127127
cli = InfluxDBClient.from_dsn('https+' + self.dsn_string)
128128
self.assertEqual('https://my.host.fr:1886', cli._baseurl)

influxdb/tests/influxdb08/client_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ def test_dsn(self):
113113
self.assertEqual('uSr', cli._username)
114114
self.assertEqual('pWd', cli._password)
115115
self.assertEqual('db', cli._database)
116-
self.assertFalse(cli.use_udp)
116+
self.assertFalse(cli._use_udp)
117117

118118
cli = InfluxDBClient.from_dsn('udp+' + self.dsn_string)
119-
self.assertTrue(cli.use_udp)
119+
self.assertTrue(cli._use_udp)
120120

121121
cli = InfluxDBClient.from_dsn('https+' + self.dsn_string)
122122
self.assertEqual('https://host:1886', cli._baseurl)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy