1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-23 11:58:49 +00:00
This commit is contained in:
pvizeli
2017-04-11 17:34:14 +02:00
committed by Pascal Vizeli
parent 318ca828cc
commit 14500d3ac4
5 changed files with 82 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
"""Tools file for HassIO."""
import asyncio
import json
import logging
import re
import socket
@@ -64,3 +65,20 @@ def get_local_ip(loop):
return socket.gethostbyname(socket.gethostname())
finally:
sock.close()
def write_json_file(jsonfile, data):
"""Write a json file."""
try:
with open(jsonfile, 'w') as conf_file:
conf_file.write(json.dumps(data))
except OSError:
return False
return True
def read_json_file(jsonfile):
"""Read a json file and return a dict."""
with open(jsonfile, 'r') as cfile:
return json.loads(cfile.read())