mirror of
https://github.com/junkfix/config-editor.git
synced 2026-05-21 12:14:49 +02:00
commit
b7ad97aba7
|
|
@ -66,8 +66,10 @@ async def websocket_create(hass, connection, msg):
|
||||||
content = ''
|
content = ''
|
||||||
res = 'Loaded'
|
res = 'Loaded'
|
||||||
try:
|
try:
|
||||||
with open(fullpath, encoding="utf-8") as fdesc:
|
def read():
|
||||||
content = fdesc.read()
|
with open(fullpath, encoding="utf-8") as fdesc:
|
||||||
|
return fdesc.read()
|
||||||
|
content = await hass.async_add_executor_job(read)
|
||||||
except:
|
except:
|
||||||
res = 'Reading Failed'
|
res = 'Reading Failed'
|
||||||
_LOGGER.exception("Reading failed: %s", fullpath)
|
_LOGGER.exception("Reading failed: %s", fullpath)
|
||||||
|
|
@ -96,12 +98,16 @@ async def websocket_create(hass, connection, msg):
|
||||||
gid = 0
|
gid = 0
|
||||||
with AtomicWriter(fullpath, overwrite=True).open() as fdesc:
|
with AtomicWriter(fullpath, overwrite=True).open() as fdesc:
|
||||||
fdesc.write(content)
|
fdesc.write(content)
|
||||||
with open(fullpath, 'a') as fdesc:
|
|
||||||
try:
|
def permi():
|
||||||
os.fchmod(fdesc.fileno(), mode)
|
with open(fullpath, 'a') as fdesc:
|
||||||
os.fchown(fdesc.fileno(), uid, gid)
|
try:
|
||||||
except:
|
os.fchmod(fdesc.fileno(), mode)
|
||||||
pass
|
os.fchown(fdesc.fileno(), uid, gid)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
await hass.async_add_executor_job(permi)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
res = "Saving Failed"
|
res = "Saving Failed"
|
||||||
_LOGGER.exception(res+": %s", fullpath)
|
_LOGGER.exception(res+": %s", fullpath)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue