refactor: use check_install_dependencies at more places where appropriate

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2024-05-02 23:26:47 +02:00
parent d84adee7f9
commit 9864dd0c7f
5 changed files with 15 additions and 25 deletions

View File

@@ -17,7 +17,7 @@ from typing import List, Dict, Literal, Union
from components.crowsnest import CROWSNEST_REPO, CROWSNEST_DIR from components.crowsnest import CROWSNEST_REPO, CROWSNEST_DIR
from components.klipper.klipper import Klipper from components.klipper.klipper import Klipper
from core.instance_manager.instance_manager import InstanceManager from core.instance_manager.instance_manager import InstanceManager
from utils.common import get_install_status from utils.common import get_install_status, check_install_dependencies
from utils.constants import COLOR_CYAN, RESET_FORMAT, CURRENT_USER from utils.constants import COLOR_CYAN, RESET_FORMAT, CURRENT_USER
from utils.git_utils import ( from utils.git_utils import (
git_clone_wrapper, git_clone_wrapper,
@@ -29,10 +29,7 @@ from utils.git_utils import (
from utils.input_utils import get_confirm from utils.input_utils import get_confirm
from utils.logger import Logger from utils.logger import Logger
from utils.sys_utils import ( from utils.sys_utils import (
check_package_install,
install_system_packages,
parse_packages_from_file, parse_packages_from_file,
update_system_package_lists,
control_systemd_service, control_systemd_service,
) )
@@ -42,9 +39,7 @@ def install_crowsnest() -> None:
git_clone_wrapper(CROWSNEST_REPO, CROWSNEST_DIR, "master") git_clone_wrapper(CROWSNEST_REPO, CROWSNEST_DIR, "master")
# Step 2: Install dependencies # Step 2: Install dependencies
requirements: List[str] = check_package_install(["make"]) check_install_dependencies(["make"])
if requirements:
install_system_packages(requirements)
# Step 3: Check for Multi Instance # Step 3: Check for Multi Instance
im = InstanceManager(Klipper) im = InstanceManager(Klipper)
@@ -114,9 +109,7 @@ def update_crowsnest() -> None:
script = CROWSNEST_DIR.joinpath("tools/install.sh") script = CROWSNEST_DIR.joinpath("tools/install.sh")
deps = parse_packages_from_file(script) deps = parse_packages_from_file(script)
packages = check_package_install(deps) check_install_dependencies(deps)
update_system_package_lists(silent=False)
install_system_packages(packages)
control_systemd_service("crowsnest", "restart") control_systemd_service("crowsnest", "restart")

View File

@@ -36,6 +36,7 @@ from components.klipper.klipper_utils import (
) )
from components.moonraker.moonraker import Moonraker from components.moonraker.moonraker import Moonraker
from core.instance_manager.instance_manager import InstanceManager from core.instance_manager.instance_manager import InstanceManager
from utils.common import check_install_dependencies
from utils.git_utils import git_clone_wrapper, git_pull_wrapper from utils.git_utils import git_clone_wrapper, git_pull_wrapper
from utils.input_utils import get_confirm from utils.input_utils import get_confirm
from utils.logger import Logger from utils.logger import Logger
@@ -43,8 +44,6 @@ from utils.sys_utils import (
parse_packages_from_file, parse_packages_from_file,
create_python_venv, create_python_venv,
install_python_requirements, install_python_requirements,
update_system_package_lists,
install_system_packages,
) )
@@ -134,8 +133,7 @@ def install_klipper_packages(klipper_dir: Path) -> None:
if Path("/boot/dietpi/.version").exists(): if Path("/boot/dietpi/.version").exists():
packages.append("dbus") packages.append("dbus")
update_system_package_lists(silent=False) check_install_dependencies(packages)
install_system_packages(packages)
def update_klipper() -> None: def update_klipper() -> None:

View File

@@ -22,7 +22,7 @@ from components.moonraker.moonraker import Moonraker
from core.backup_manager.backup_manager import BackupManager from core.backup_manager.backup_manager import BackupManager
from core.instance_manager.instance_manager import InstanceManager from core.instance_manager.instance_manager import InstanceManager
from core.settings.kiauh_settings import KiauhSettings from core.settings.kiauh_settings import KiauhSettings
from utils.common import get_install_status from utils.common import get_install_status, check_install_dependencies
from utils.config_utils import add_config_section, remove_config_section from utils.config_utils import add_config_section, remove_config_section
from utils.constants import SYSTEMD from utils.constants import SYSTEMD
from utils.fs_utils import remove_with_sudo from utils.fs_utils import remove_with_sudo
@@ -37,8 +37,6 @@ from utils.input_utils import get_confirm
from utils.logger import Logger from utils.logger import Logger
from utils.sys_utils import ( from utils.sys_utils import (
check_python_version, check_python_version,
check_package_install,
install_system_packages,
control_systemd_service, control_systemd_service,
install_python_requirements, install_python_requirements,
) )
@@ -62,9 +60,7 @@ def install_klipperscreen() -> None:
return return
package_list = ["wget", "curl", "unzip", "dfu-util"] package_list = ["wget", "curl", "unzip", "dfu-util"]
packages = check_package_install(package_list) check_install_dependencies(package_list)
if packages:
install_system_packages(packages)
git_clone_wrapper(KLIPPERSCREEN_REPO, KLIPPERSCREEN_DIR) git_clone_wrapper(KLIPPERSCREEN_REPO, KLIPPERSCREEN_DIR)

View File

@@ -34,6 +34,7 @@ from components.moonraker.moonraker_utils import (
backup_moonraker_dir, backup_moonraker_dir,
) )
from core.instance_manager.instance_manager import InstanceManager from core.instance_manager.instance_manager import InstanceManager
from utils.common import check_install_dependencies
from utils.fs_utils import check_file_exist from utils.fs_utils import check_file_exist
from utils.git_utils import git_clone_wrapper, git_pull_wrapper from utils.git_utils import git_clone_wrapper, git_pull_wrapper
from utils.input_utils import ( from utils.input_utils import (
@@ -45,8 +46,6 @@ from utils.sys_utils import (
parse_packages_from_file, parse_packages_from_file,
create_python_venv, create_python_venv,
install_python_requirements, install_python_requirements,
update_system_package_lists,
install_system_packages,
check_python_version, check_python_version,
) )
@@ -143,8 +142,7 @@ def setup_moonraker_prerequesites() -> None:
def install_moonraker_packages(moonraker_dir: Path) -> None: def install_moonraker_packages(moonraker_dir: Path) -> None:
script = moonraker_dir.joinpath("scripts/install-moonraker.sh") script = moonraker_dir.joinpath("scripts/install-moonraker.sh")
packages = parse_packages_from_file(script) packages = parse_packages_from_file(script)
update_system_package_lists(silent=False) check_install_dependencies(packages)
install_system_packages(packages)
def install_moonraker_polkit() -> None: def install_moonraker_polkit() -> None:

View File

@@ -23,7 +23,11 @@ from utils.constants import (
COLOR_RED, COLOR_RED,
) )
from utils.logger import Logger from utils.logger import Logger
from utils.sys_utils import check_package_install, install_system_packages from utils.sys_utils import (
check_package_install,
install_system_packages,
update_system_package_lists,
)
def get_current_date() -> Dict[Literal["date", "time"], str]: def get_current_date() -> Dict[Literal["date", "time"], str]:
@@ -51,6 +55,7 @@ def check_install_dependencies(deps: List[str]) -> None:
Logger.print_info("The following packages need installation:") Logger.print_info("The following packages need installation:")
for _ in requirements: for _ in requirements:
print(f"{COLOR_CYAN}{_}{RESET_FORMAT}") print(f"{COLOR_CYAN}{_}{RESET_FORMAT}")
update_system_package_lists(silent=False)
install_system_packages(requirements) install_system_packages(requirements)