mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-20 05:17:56 +00:00
Replace JSONDecodeError by ValueError (Python 3.4 compatibility)
Fix #847
This commit is contained in:
parent
8c61ef18ba
commit
e53db1ed81
@ -127,7 +127,7 @@ class Controller:
|
|||||||
self.save()
|
self.save()
|
||||||
with open(self._config_file) as f:
|
with open(self._config_file) as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
except (OSError, json.decoder.JSONDecodeError) as e:
|
except (OSError, ValueError) as e:
|
||||||
log.critical("Cannot load %s: %s", self._config_file, str(e))
|
log.critical("Cannot load %s: %s", self._config_file, str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ class VirtualBoxGNS3VM(BaseGNS3VM):
|
|||||||
if resp:
|
if resp:
|
||||||
try:
|
try:
|
||||||
json_data = yield from resp.json()
|
json_data = yield from resp.json()
|
||||||
except json.decoder.JSONDecodeError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
resp.close()
|
resp.close()
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ def load_topology(path):
|
|||||||
try:
|
try:
|
||||||
with open(path, encoding="utf-8") as f:
|
with open(path, encoding="utf-8") as f:
|
||||||
topo = json.load(f)
|
topo = json.load(f)
|
||||||
except (OSError, UnicodeDecodeError, json.decoder.JSONDecodeError) as e:
|
except (OSError, UnicodeDecodeError, ValueError) as e:
|
||||||
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
|
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
|
||||||
if "revision" not in topo or topo["revision"] < 5:
|
if "revision" not in topo or topo["revision"] < 5:
|
||||||
# If it's an old GNS3 file we need to convert it
|
# If it's an old GNS3 file we need to convert it
|
||||||
|
@ -227,7 +227,7 @@ async def main(loop):
|
|||||||
try:
|
try:
|
||||||
j = await error.response.json()
|
j = await error.response.json()
|
||||||
die("%s %s invalid status %d:\n%s", error.method, error.path, error.response.status, json.dumps(j, indent=4))
|
die("%s %s invalid status %d:\n%s", error.method, error.path, error.response.status, json.dumps(j, indent=4))
|
||||||
except (json.decoder.JSONDecodeError, aiohttp.errors.ServerDisconnectedError):
|
except (ValueError, aiohttp.errors.ServerDisconnectedError):
|
||||||
die("%s %s invalid status %d", error.method, error.path, error.response.status)
|
die("%s %s invalid status %d", error.method, error.path, error.response.status)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user