refactor: extract check for python version into function
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from components.webui_client.client_utils import (
|
from components.webui_client.client_utils import (
|
||||||
@@ -48,6 +47,7 @@ from utils.sys_utils import (
|
|||||||
install_python_requirements,
|
install_python_requirements,
|
||||||
update_system_package_lists,
|
update_system_package_lists,
|
||||||
install_system_packages,
|
install_system_packages,
|
||||||
|
check_python_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -116,18 +116,15 @@ def install_moonraker() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def check_moonraker_install_requirements() -> bool:
|
def check_moonraker_install_requirements() -> bool:
|
||||||
if not (sys.version_info.major >= 3 and sys.version_info.minor >= 7):
|
def check_klipper_instances() -> bool:
|
||||||
Logger.print_error("Versioncheck failed!")
|
if len(InstanceManager(Klipper).instances) >= 1:
|
||||||
Logger.print_error("Python 3.7 or newer required to run Moonraker.")
|
return True
|
||||||
return False
|
|
||||||
|
|
||||||
kl_instance_count = len(InstanceManager(Klipper).instances)
|
|
||||||
if kl_instance_count < 1:
|
|
||||||
Logger.print_warn("Klipper not installed!")
|
Logger.print_warn("Klipper not installed!")
|
||||||
Logger.print_warn("Moonraker cannot be installed! Install Klipper first.")
|
Logger.print_warn("Moonraker cannot be installed! Install Klipper first.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return check_python_version(3, 7) and check_klipper_instances()
|
||||||
|
|
||||||
|
|
||||||
def setup_moonraker_prerequesites() -> None:
|
def setup_moonraker_prerequesites() -> None:
|
||||||
|
|||||||
@@ -39,6 +39,20 @@ def kill(opt_err_msg: str = "") -> None:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def check_python_version(major: int, minor: int) -> bool:
|
||||||
|
"""
|
||||||
|
Checks the python version and returns True if it's at least the given version
|
||||||
|
:param major: the major version to check
|
||||||
|
:param minor: the minor version to check
|
||||||
|
:return: bool
|
||||||
|
"""
|
||||||
|
if not (sys.version_info.major >= major and sys.version_info.minor >= minor):
|
||||||
|
Logger.print_error("Versioncheck failed!")
|
||||||
|
Logger.print_error(f"Python {major}.{minor} or newer required.")
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def parse_packages_from_file(source_file: Path) -> List[str]:
|
def parse_packages_from_file(source_file: Path) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Read the package names from bash scripts, when defined like:
|
Read the package names from bash scripts, when defined like:
|
||||||
|
|||||||
Reference in New Issue
Block a user