mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Update dependency check in __main__
This commit is contained in:
parent
a752bc012c
commit
09f1983d40
@ -7,6 +7,14 @@ import argparse
|
|||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
|
|
||||||
|
# Home Assistant dependencies, mapped module -> package name
|
||||||
|
DEPENDENCIES = {
|
||||||
|
'requests': 'requests',
|
||||||
|
'yaml': 'pyyaml',
|
||||||
|
'pytz': 'pytz',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def validate_python():
|
def validate_python():
|
||||||
""" Validate we're running the right Python version. """
|
""" Validate we're running the right Python version. """
|
||||||
major, minor = sys.version_info[:2]
|
major, minor = sys.version_info[:2]
|
||||||
@ -20,13 +28,13 @@ def validate_dependencies():
|
|||||||
""" Validate all dependencies that HA uses. """
|
""" Validate all dependencies that HA uses. """
|
||||||
import_fail = False
|
import_fail = False
|
||||||
|
|
||||||
for module in ['requests']:
|
for module, name in DEPENDENCIES.items():
|
||||||
try:
|
try:
|
||||||
importlib.import_module(module)
|
importlib.import_module(module)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import_fail = True
|
import_fail = True
|
||||||
print(
|
print(
|
||||||
'Fatal Error: Unable to find dependency {}'.format(module))
|
'Fatal Error: Unable to find dependency {}'.format(name))
|
||||||
|
|
||||||
if import_fail:
|
if import_fail:
|
||||||
print(("Install dependencies by running: "
|
print(("Install dependencies by running: "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user