Skip to content

Commit 8afb8e2

Browse files
committed
Fix indent. Impl delete method
1 parent 494e654 commit 8afb8e2

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

influxdb/client.py

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,39 +69,61 @@ def write_points(self, data):
6969
if response.status_code == 200:
7070
return True
7171
else:
72-
raise Exception("{0}: {1}".format(response.status_code, response.content))
72+
raise Exception(
73+
"{0}: {1}".format(response.status_code, response.content))
7374

7475
def write_points_with_time_precision(self, data, time_precision='s'):
7576
"""
7677
Write to multiple time series names
7778
"""
7879
if time_precision not in ['s', 'm', 'u']:
79-
raise Exception("Invalid time precision is given. (use 's','m' or 'u')")
80+
raise Exception(
81+
"Invalid time precision is given. (use 's','m' or 'u')")
8082

8183
url_format = "{0}/db/{1}/series?u={2}&p={3}&time_precision={4}"
8284

8385
response = requests.post(url_format.format(
84-
self._baseurl,
85-
self._database,
86-
self._username,
87-
self._password,
88-
time_precision),
86+
self._baseurl,
87+
self._database,
88+
self._username,
89+
self._password,
90+
time_precision),
8991
data=json.dumps(data),
9092
headers=self._headers)
9193

9294
if response.status_code == 200:
9395
return True
9496
else:
95-
raise Exception("{0}: {1}".format(response.status_code, response.content))
97+
raise Exception(
98+
"{0}: {1}".format(response.status_code, response.content))
9699

97100
# One Time Deletes
98101

99102
def delete_points(self, name,
100103
regex=None, start_epoch=None, end_epoch=None):
101104
"""
102-
TODO: One Time Deletes
105+
Delete a range of data
103106
"""
104-
raise NotImplemented()
107+
url_format = "{0}/db/{1}/series?u={2}&p={3}"
108+
url_format += "&name={4}"
109+
if regex is not None:
110+
url_format += "&regex=" + regex
111+
if start_epoch is not None:
112+
url_format += "&start=" + start_epoch
113+
if end_epoch is not None:
114+
url_format += "&end=" + end_epoch
115+
116+
response = requests.delete(url_format.format(
117+
self._baseurl,
118+
self._database,
119+
self._username,
120+
self._password,
121+
name))
122+
if response.status_code == 200:
123+
return True
124+
else:
125+
raise Exception(
126+
"{0}: {1}".format(response.status_code, response.content))
105127

106128
# Regularly Scheduled Deletes
107129

@@ -137,7 +159,8 @@ def query(self, query, time_precision='s', chunked=False):
137159
Quering data
138160
"""
139161
if time_precision not in ['s', 'm', 'u']:
140-
raise Exception("Invalid time precision is given. (use 's','m' or 'u')")
162+
raise Exception(
163+
"Invalid time precision is given. (use 's','m' or 'u')")
141164

142165
if chunked is True:
143166
chunked_param = 'true'
@@ -162,7 +185,8 @@ def query(self, query, time_precision='s', chunked=False):
162185
if response.status_code == 200:
163186
return response.content
164187
else:
165-
raise Exception("{0}: {1}".format(response.status_code, response.content))
188+
raise Exception(
189+
"{0}: {1}".format(response.status_code, response.content))
166190

167191
# Creating and Dropping Databases
168192
#
@@ -211,7 +235,8 @@ def delete_database(self, database):
211235
if response.status_code == 204:
212236
return True
213237
else:
214-
raise Exception("{0}: {1}".format(response.status_code, response.content))
238+
raise Exception(
239+
"{0}: {1}".format(response.status_code, response.content))
215240

216241
# Security
217242
# get list of cluster admins
@@ -256,7 +281,8 @@ def get_list_cluster_admins(self):
256281
if response.status_code == 200:
257282
return json.loads(response.content)
258283
else:
259-
raise Exception("{0}: {1}".format(response.status_code, response.content))
284+
raise Exception(
285+
"{0}: {1}".format(response.status_code, response.content))
260286

261287
def add_cluster_admin(self, new_username, new_password):
262288
"""
@@ -275,7 +301,8 @@ def add_cluster_admin(self, new_username, new_password):
275301
if response.status_code == 200:
276302
return True
277303
else:
278-
raise Exception("{0}: {1}".format(response.status_code, response.content))
304+
raise Exception(
305+
"{0}: {1}".format(response.status_code, response.content))
279306

280307
def update_cluster_admin_password(self, username, new_password):
281308
"""

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