Loader no longer crashes if custom_components folder does not exists in the config dir

This commit is contained in:
Paulus Schoutsen 2014-11-05 07:56:36 -08:00
parent 4c5bad495f
commit aa80841519

View File

@ -20,11 +20,7 @@ _LOGGER = logging.getLogger(__name__)
def prepare(hass):
""" Prepares the loading of components. """
# Ensure we can load custom components from the config dir
sys.path.append(hass.config_dir)
# pylint: disable=import-error
import custom_components
# Load the built-in components
import homeassistant.components as components
AVAILABLE_COMPONENTS.clear()
@ -33,9 +29,23 @@ def prepare(hass):
item[1] for item in
pkgutil.iter_modules(components.__path__, 'homeassistant.components.'))
AVAILABLE_COMPONENTS.extend(
item[1] for item in
pkgutil.iter_modules(custom_components.__path__, 'custom_components.'))
# Look for available 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):