Merge pull request #323 from andythigpen/skip-pip

Add option to skip pip install on startup.
This commit is contained in:
Paulus Schoutsen 2015-09-04 16:06:30 -07:00
commit 03d187eceb
3 changed files with 25 additions and 7 deletions

View File

@ -77,6 +77,10 @@ def get_arguments():
'--open-ui',
action='store_true',
help='Open the webinterface in a browser')
parser.add_argument(
'--skip-pip',
action='store_true',
help='Skips pip install of required packages on startup')
parser.add_argument(
'-v', '--verbose',
action='store_true',
@ -161,15 +165,19 @@ def main():
write_pid(args.pid_file)
if args.demo_mode:
hass = bootstrap.from_config_dict({
config = {
'frontend': {},
'demo': {}
}, config_dir=config_dir, daemon=args.daemon, verbose=args.verbose)
}
hass = bootstrap.from_config_dict(
config, config_dir=config_dir, daemon=args.daemon,
verbose=args.verbose, skip_pip=args.skip_pip)
else:
config_file = ensure_config_file(config_dir)
print('Config directory:', config_dir)
hass = bootstrap.from_config_file(
config_file, daemon=args.daemon, verbose=args.verbose)
config_file, daemon=args.daemon, verbose=args.verbose,
skip_pip=args.skip_pip)
if args.open_ui:
def open_browser(event):

View File

@ -61,7 +61,7 @@ def setup_component(hass, domain, config=None):
def _handle_requirements(hass, component, name):
""" Installs requirements for component. """
if not hasattr(component, 'REQUIREMENTS'):
if hass.config.skip_pip or not hasattr(component, 'REQUIREMENTS'):
return True
for req in component.REQUIREMENTS:
@ -151,7 +151,7 @@ def mount_local_lib_path(config_dir):
# pylint: disable=too-many-branches, too-many-statements, too-many-arguments
def from_config_dict(config, hass=None, config_dir=None, enable_log=True,
verbose=False, daemon=False):
verbose=False, daemon=False, skip_pip=False):
"""
Tries to configure Home Assistant from a config dict.
@ -169,6 +169,11 @@ def from_config_dict(config, hass=None, config_dir=None, enable_log=True,
if enable_log:
enable_logging(hass, verbose, daemon)
hass.config.skip_pip = skip_pip
if skip_pip:
_LOGGER.warning('Skipping pip installation of required modules. '
'This may cause issues.')
_ensure_loader_prepared(hass)
# Make a copy because we are mutating it.
@ -196,7 +201,8 @@ def from_config_dict(config, hass=None, config_dir=None, enable_log=True,
return hass
def from_config_file(config_path, hass=None, verbose=False, daemon=False):
def from_config_file(config_path, hass=None, verbose=False, daemon=False,
skip_pip=True):
"""
Reads the configuration file and tries to start all the required
functionality. Will add functionality to 'hass' parameter if given,
@ -214,7 +220,8 @@ def from_config_file(config_path, hass=None, verbose=False, daemon=False):
config_dict = config_util.load_config_file(config_path)
return from_config_dict(config_dict, hass, enable_log=False)
return from_config_dict(config_dict, hass, enable_log=False,
skip_pip=skip_pip)
def enable_logging(hass, verbose=False, daemon=False):

View File

@ -664,6 +664,9 @@ class Config(object):
self.location_name = None
self.time_zone = None
# If True, pip install is skipped for requirements on startup
self.skip_pip = False
# List of loaded components
self.components = []