mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Protect loop set default executor (#37438)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
"""Script to check the configuration file."""
|
||||
import argparse
|
||||
import asyncio
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Mapping, Sequence
|
||||
from glob import glob
|
||||
@ -199,12 +200,7 @@ def check(config_dir, secrets=False):
|
||||
yaml_loader.yaml.SafeLoader.add_constructor("!secret", yaml_loader.secret_yaml)
|
||||
|
||||
try:
|
||||
hass = core.HomeAssistant()
|
||||
hass.config.config_dir = config_dir
|
||||
|
||||
res["components"] = hass.loop.run_until_complete(
|
||||
async_check_ha_config_file(hass)
|
||||
)
|
||||
res["components"] = asyncio.run(async_check_config(config_dir))
|
||||
res["secret_cache"] = OrderedDict(yaml_loader.__SECRET_CACHE)
|
||||
for err in res["components"].errors:
|
||||
domain = err.domain or ERROR_STR
|
||||
@ -213,7 +209,6 @@ def check(config_dir, secrets=False):
|
||||
res["except"].setdefault(domain, []).append(err.config)
|
||||
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
_LOGGER.exception("BURB")
|
||||
print(color("red", "Fatal error while loading config:"), str(err))
|
||||
res["except"].setdefault(ERROR_STR, []).append(str(err))
|
||||
finally:
|
||||
@ -230,6 +225,15 @@ def check(config_dir, secrets=False):
|
||||
return res
|
||||
|
||||
|
||||
async def async_check_config(config_dir):
|
||||
"""Check the HA config."""
|
||||
hass = core.HomeAssistant()
|
||||
hass.config.config_dir = config_dir
|
||||
components = await async_check_ha_config_file(hass)
|
||||
await hass.async_stop(force=True)
|
||||
return components
|
||||
|
||||
|
||||
def line_info(obj, **kwargs):
|
||||
"""Display line config source."""
|
||||
if hasattr(obj, "__config_file__"):
|
||||
|
Reference in New Issue
Block a user