From 8e5f7d08389fde9e85b15e90c29ffd2bb52d19bc Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 3 May 2017 17:28:47 +0200 Subject: [PATCH] Catch error when writting the topology file on read only device Fix #1003 --- gns3server/controller/topology.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py index ee27a652..5008817f 100644 --- a/gns3server/controller/topology.py +++ b/gns3server/controller/topology.py @@ -146,8 +146,11 @@ def load_topology(path): raise e if changed: - with open(path, "w+", encoding="utf-8") as f: - json.dump(topo, f, indent=4, sort_keys=True) + try: + with open(path, "w+", encoding="utf-8") as f: + json.dump(topo, f, indent=4, sort_keys=True) + except (OSError) as e: + raise aiohttp.web.HTTPConflict(text="Can't write the topology {}: {}".format(path, str(e))) return topo