Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions homeassistant/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from homeassistant.bootstrap import async_mount_local_lib_path
from homeassistant.config import get_default_config_dir
from homeassistant import requirements
from homeassistant.core import HomeAssistant
from homeassistant.requirements import pip_kwargs, PackageLoadable
from homeassistant.util.package import install_package, is_virtual_env


Expand Down Expand Up @@ -39,16 +40,25 @@ def run(args: List) -> int:

config_dir = extract_config_dir()

loop = asyncio.get_event_loop()

if not is_virtual_env():
asyncio.get_event_loop().run_until_complete(
async_mount_local_lib_path(config_dir))
loop.run_until_complete(async_mount_local_lib_path(config_dir))

pip_kwargs = requirements.pip_kwargs(config_dir)
_pip_kwargs = pip_kwargs(config_dir)

logging.basicConfig(stream=sys.stdout, level=logging.INFO)

hass = HomeAssistant(loop)
pkgload = PackageLoadable(hass)
for req in getattr(script, 'REQUIREMENTS', []):
returncode = install_package(req, **pip_kwargs)
try:
loop.run_until_complete(pkgload.loadable(req))
continue
except ImportError:
pass

returncode = install_package(req, **_pip_kwargs)

if not returncode:
print('Aborting script, could not install dependency', req)
Expand Down
3 changes: 0 additions & 3 deletions homeassistant/scripts/check_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
from collections import OrderedDict, namedtuple
from glob import glob
from platform import system
from typing import Dict, List, Sequence
from unittest.mock import patch

Expand All @@ -22,8 +21,6 @@
from homeassistant.exceptions import HomeAssistantError

REQUIREMENTS = ('colorlog==4.0.2',)
if system() == 'Windows': # Ensure colorama installed for colorlog on Windows
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s automatic these days. In the past you needed colorlog[windows]

See https://pypi.org/project/colorlog/ search windows/colorama

REQUIREMENTS += ('colorama<=1',)

_LOGGER = logging.getLogger(__name__)
# pylint: disable=protected-access
Expand Down