some compatibility fix

This commit is contained in:
Dmitriy
2018-11-20 22:21:26 +03:00
parent c33f95e0b5
commit a92b7526eb

View File

@@ -223,7 +223,7 @@ def http(user, password, url, callback):
while True:
url = yield
with urlopen(url, timeout=5) as f:
msg = json.load(f).get("message", None)
msg = json.loads(f.read().decode("utf-8")).get("message", None)
if msg:
callback("HTTP: {}\n".format(msg))
@@ -270,10 +270,11 @@ def http_request(host, port, user, password):
try:
with urlopen(url, timeout=5) as f:
yield json.load(f)
yield json.loads(f.read().decode("utf-8"))
except (URLError, HTTPError):
yield None
# ***************** Connections testing *******************#
@@ -293,7 +294,7 @@ def test_http(host, port, user, password, timeout=5):
init_auth(user, password, url)
with urlopen(url, timeout=5) as f:
return json.load(f).get("message", "")
return json.loads(f.read().decode("utf-8")).get("message", "")
except (URLError, HTTPError) as e:
raise TestException(e)