diff --git a/homeassistant/scripts/__init__.py b/homeassistant/scripts/__init__.py index 3050379a496..070d907a7d9 100644 --- a/homeassistant/scripts/__init__.py +++ b/homeassistant/scripts/__init__.py @@ -52,15 +52,10 @@ def run(args: List) -> int: hass = HomeAssistant(loop) pkgload = PackageLoadable(hass) for req in getattr(script, 'REQUIREMENTS', []): - try: - loop.run_until_complete(pkgload.loadable(req)) + if loop.run_until_complete(pkgload.loadable(req)): continue - except ImportError: - pass - returncode = install_package(req, **_pip_kwargs) - - if not returncode: + if not install_package(req, **_pip_kwargs): print('Aborting script, could not install dependency', req) return 1 diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index cae937102cc..1b8c6719395 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -41,20 +41,15 @@ ERROR_STR = 'General Errors' def color(the_color, *args, reset=None): """Color helper.""" + from colorlog.escape_codes import escape_codes, parse_colors try: - from colorlog.escape_codes import escape_codes, parse_colors - try: - if not args: - assert reset is None, "Cannot reset if nothing being printed" - return parse_colors(the_color) - return parse_colors(the_color) + ' '.join(args) + \ - escape_codes[reset or 'reset'] - except KeyError as k: - raise ValueError( - "Invalid color {} in {}".format(str(k), the_color)) - except ImportError: - # We should fallback to black-and-white if colorlog is not installed - return ' '.join(args) + if not args: + assert reset is None, "You cannot reset if nothing being printed" + return parse_colors(the_color) + return parse_colors(the_color) + ' '.join(args) + \ + escape_codes[reset or 'reset'] + except KeyError as k: + raise ValueError("Invalid color {} in {}".format(str(k), the_color)) def run(script_args: List) -> int: