Commit 637e2bd5 authored by Patrick Godwin's avatar Patrick Godwin
Browse files

decode html responses to unicode for python 3 compatibility

parent 5e6d6b8a
Pipeline #50223 passed with stages
in 1 minute and 58 seconds
......@@ -51,7 +51,7 @@ def get_url(url, d):
"""
f = "%s%s.txt" % (url, d)
try:
jobdata = urllib.request.urlopen(f).read().split("\n")
jobdata = urllib.request.urlopen(f).read().decode('utf-8').split("\n")
except urllib.error.HTTPError as e:
logging.error("%s : %s" % (f, str(e)))
return
......
......@@ -351,7 +351,7 @@ def retrieve_timeseries_by_tag(client, db, measurement, start, end, column, tag,
params = urllib.parse.urlencode({'db':db, 'q':query, 'epoch':epoch})
client.request('GET', '/query?{}'.format(params), headers={"Content-Type": "application/json"})
response = json.loads(client.getresponse().read())
response = json.loads(client.getresponse().read().decode('utf-8'))
try:
points = response['results'][0]['series'][0]['values']
except:
......@@ -410,7 +410,7 @@ def retrieve_timeseries_latest(client, db, measurement, column, tags=None, aggre
params = urllib.parse.urlencode({'db':db, 'q':query, 'epoch':epoch})
client.request('GET', '/query?{}'.format(params), headers={"Content-Type": "application/json"})
response = json.loads(client.getresponse().read())
response = json.loads(client.getresponse().read().decode('utf-8'))
try:
points = response['results'][0]['series'][0]['values']
......@@ -467,7 +467,7 @@ def retrieve_timeseries(client, db, measurement, start, end, column, tags=None,
params = urllib.parse.urlencode({'db':db, 'q':query, 'epoch':epoch})
client.request('GET', '/query?{}'.format(params), headers={"Content-Type": "application/json"})
response = json.loads(client.getresponse().read())
response = json.loads(client.getresponse().read().decode('utf-8'))
try:
points = response['results'][0]['series'][0]['values']
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment