1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-13 20:08:55 +00:00

Fix utf8 errors

Fix #681
This commit is contained in:
Julien Duponchelle 2016-09-18 22:23:52 +02:00
parent ac8bd3fec4
commit cf10f02a8d
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 3 additions and 3 deletions

View File

@ -648,7 +648,7 @@ class Project:
topo = project_to_topology(self)
path = self._topology_file()
log.debug("Write %s", path)
with open(path + ".tmp", "w+") as f:
with open(path + ".tmp", "w+", encoding="utf-8") as f:
json.dump(topo, f, indent=4, sort_keys=True)
shutil.move(path + ".tmp", path)
except OSError as e:

View File

@ -89,7 +89,7 @@ def load_topology(path):
"""
log.debug("Read topology %s", path)
try:
with open(path) as f:
with open(path, encoding="utf-8") as f:
topo = json.load(f)
except (OSError, UnicodeEncodeError, json.JSONDecodeError) as e:
raise aiohttp.web.HTTPConflict(text="Could not load topology {}: {}".format(path, str(e)))
@ -98,7 +98,7 @@ def load_topology(path):
# first we backup the file
shutil.copy(path, path + ".backup")
topo = _convert_1_3_later(topo, path)
with open(path, "w+") as f:
with open(path, "w+", encoding="utf-8") as f:
json.dump(topo, f)
elif topo["revision"] > GNS3_FILE_FORMAT_REVISION:
raise aiohttp.web.HTTPConflict(text="This project is designed for a more recent version of GNS3 please update GNS3 to version {} or later".format(topo["version"]))