From 85ffba90b2973bfacfaa89cd77961d8d4a2457af Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 30 Apr 2017 01:57:03 +0200 Subject: [PATCH] Fix severals things with json (#22) --- hassio/tools.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hassio/tools.py b/hassio/tools.py index 3ee864de9..a012d3361 100644 --- a/hassio/tools.py +++ b/hassio/tools.py @@ -77,9 +77,10 @@ def get_local_ip(loop): def write_json_file(jsonfile, data): """Write a json file.""" try: + json_str = json.dumps(data, indent=2) with open(jsonfile, 'w') as conf_file: - conf_file.write(json.dumps(data)) - except OSError: + conf_file.write(json_str) + except (OSError, json.JSONDecodeError): return False return True