mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Loader no longer crashes if custom_components folder does not exists in the config dir
This commit is contained in:
parent
4c5bad495f
commit
aa80841519
@ -20,11 +20,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def prepare(hass):
|
def prepare(hass):
|
||||||
""" Prepares the loading of components. """
|
""" Prepares the loading of components. """
|
||||||
# Ensure we can load custom components from the config dir
|
# Load the built-in components
|
||||||
sys.path.append(hass.config_dir)
|
|
||||||
|
|
||||||
# pylint: disable=import-error
|
|
||||||
import custom_components
|
|
||||||
import homeassistant.components as components
|
import homeassistant.components as components
|
||||||
|
|
||||||
AVAILABLE_COMPONENTS.clear()
|
AVAILABLE_COMPONENTS.clear()
|
||||||
@ -33,9 +29,23 @@ def prepare(hass):
|
|||||||
item[1] for item in
|
item[1] for item in
|
||||||
pkgutil.iter_modules(components.__path__, 'homeassistant.components.'))
|
pkgutil.iter_modules(components.__path__, 'homeassistant.components.'))
|
||||||
|
|
||||||
AVAILABLE_COMPONENTS.extend(
|
# Look for available custom components
|
||||||
item[1] for item in
|
|
||||||
pkgutil.iter_modules(custom_components.__path__, 'custom_components.'))
|
# Ensure we can load custom components from the config dir
|
||||||
|
sys.path.append(hass.config_dir)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# pylint: disable=import-error
|
||||||
|
import custom_components
|
||||||
|
|
||||||
|
AVAILABLE_COMPONENTS.extend(
|
||||||
|
item[1] for item in
|
||||||
|
pkgutil.iter_modules(
|
||||||
|
custom_components.__path__, 'custom_components.'))
|
||||||
|
|
||||||
|
except ImportError:
|
||||||
|
# No folder custom_components exist in the config directory
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_component(comp_name):
|
def get_component(comp_name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user