Validate operating system is supported (#64352)

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Erik Montnemery 2022-01-18 22:16:23 +01:00 committed by GitHub
parent 5a1e5e1cef
commit c285743621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,13 @@ from .const import REQUIRED_PYTHON_VER, RESTART_EXIT_CODE, __version__
FAULT_LOG_FILENAME = "home-assistant.log.fault"
def validate_os() -> None:
"""Validate that Home Assistant is running in a supported operating system."""
if not sys.platform.startswith(("darwin", "linux")):
print("Home Assistant only supports Linux, OSX and Windows using WSL")
sys.exit(1)
def validate_python() -> None:
"""Validate that the right Python version is running."""
if sys.version_info[:3] < REQUIRED_PYTHON_VER:
@ -108,6 +115,11 @@ def get_arguments() -> argparse.Namespace:
parser.add_argument(
"--script", nargs=argparse.REMAINDER, help="Run one of the embedded scripts"
)
parser.add_argument(
"--ignore-os-check",
action="store_true",
help="Skips validation of operating system",
)
arguments = parser.parse_args()
@ -146,6 +158,9 @@ def main() -> int:
args = get_arguments()
if not args.ignore_os_check:
validate_os()
if args.script is not None:
# pylint: disable=import-outside-toplevel
from . import scripts