1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-22 19:39:18 +00:00

Code cleanup & add config check to API (#155)

* Code cleanup & add config check to API

* Fix comments

* fix lint p1

* Fix lint p2

* fix coro

* fix parameter

* add log output

* fix command layout

* fix Pannel

* fix lint p4

* fix regex

* convert to ascii

* fix lint p5

* add temp logging

* fix output on non-zero exit

* remove temporary log
This commit is contained in:
Pascal Vizeli
2017-08-16 02:10:38 +02:00
committed by GitHub
parent 4af92b9d25
commit 7798e7cde2
14 changed files with 173 additions and 146 deletions

View File

@@ -2,16 +2,19 @@
import asyncio
import logging
import os
import re
from .const import (
FILE_HASSIO_HOMEASSISTANT, ATTR_DEVICES, ATTR_IMAGE, ATTR_LAST_VERSION,
ATTR_VERSION)
from .dock.homeassistant import DockerHomeAssistant
from .tools import JsonConfig
from .tools import JsonConfig, convert_to_ascii
from .validate import SCHEMA_HASS_CONFIG
_LOGGER = logging.getLogger(__name__)
RE_CONFIG_CHECK = re.compile(r"error", re.IGNORECASE)
class HomeAssistant(JsonConfig):
"""Hass core object for handle it."""
@@ -165,3 +168,20 @@ class HomeAssistant(JsonConfig):
def in_progress(self):
"""Return True if a task is in progress."""
return self.docker.in_progress
async def check_config(self):
"""Run homeassistant config check."""
log = await self.docker.execute_command(
"python3 -m homeassistant -c /config --script check_config"
)
# if not valid
if not log:
return (False, "")
# parse output
log = convert_to_ascii(log)
if RE_CONFIG_CHECK.search(log):
return (False, log)
return (True, log)