Migrate check-config to use get_integration (#23026)

* Migrate check-config to use get_integration

* ImportError
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-04-12 10:14:16 -07:00
1 parent 2c07bfb9e0
commit f269135ae9
2 files changed
+24 -6

No files matched your search

+21 -4
View File
@@ -329,8 +329,16 @@ def check_ha_config_file(hass):
# Process and validate config
for domain in components:
component = loader.get_component(hass, domain)
if not component:
try:
integration = hass.loop.run_until_complete(
loader.async_get_integration(hass, domain))
except loader.IntegrationNotFound:
result.add_error("Integration not found: {}".format(domain))
continue
try:
component = integration.get_component()
except ImportError:
result.add_error("Component not found: {}".format(domain))
continue
@@ -368,9 +376,18 @@ def check_ha_config_file(hass):
platforms.append(p_validated)
continue
platform = loader.get_platform(hass, domain, p_name)
try:
p_integration = hass.loop.run_until_complete(
loader.async_get_integration(hass, p_name))
except loader.IntegrationNotFound:
result.add_error(
"Integration {} not found when trying to verify its {} "
"platform.".format(p_name, domain))
continue
if platform is None:
try:
platform = p_integration.get_platform(domain)
except ImportError:
result.add_error(
"Platform not found: {}.{}".format(domain, p_name))
continue