mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-26 01:03:35 +05:00
refactor: check_install_dependencies expects a set now
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -52,7 +52,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
|
||||||
check_install_dependencies(["make"])
|
check_install_dependencies({"make"})
|
||||||
|
|
||||||
# Step 3: Check for Multi Instance
|
# Step 3: Check for Multi Instance
|
||||||
im = InstanceManager(Klipper)
|
im = InstanceManager(Klipper)
|
||||||
@@ -139,7 +139,7 @@ def update_crowsnest() -> None:
|
|||||||
git_pull_wrapper(CROWSNEST_REPO, CROWSNEST_DIR)
|
git_pull_wrapper(CROWSNEST_REPO, CROWSNEST_DIR)
|
||||||
|
|
||||||
deps = parse_packages_from_file(CROWSNEST_INSTALL_SCRIPT)
|
deps = parse_packages_from_file(CROWSNEST_INSTALL_SCRIPT)
|
||||||
check_install_dependencies(deps)
|
check_install_dependencies({*deps})
|
||||||
|
|
||||||
cmd_sysctl_service(CROWSNEST_SERVICE_NAME, "restart")
|
cmd_sysctl_service(CROWSNEST_SERVICE_NAME, "restart")
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ def install_klipper_packages() -> None:
|
|||||||
if Path("/boot/dietpi/.version").exists():
|
if Path("/boot/dietpi/.version").exists():
|
||||||
packages.append("dbus")
|
packages.append("dbus")
|
||||||
|
|
||||||
check_install_dependencies(packages)
|
check_install_dependencies({*packages})
|
||||||
|
|
||||||
|
|
||||||
def update_klipper() -> None:
|
def update_klipper() -> None:
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ def install_klipperscreen() -> None:
|
|||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
package_list = ["git", "wget", "curl", "unzip", "dfu-util"]
|
check_install_dependencies()
|
||||||
check_install_dependencies(package_list)
|
|
||||||
|
|
||||||
git_clone_wrapper(KLIPPERSCREEN_REPO, KLIPPERSCREEN_DIR)
|
git_clone_wrapper(KLIPPERSCREEN_REPO, KLIPPERSCREEN_DIR)
|
||||||
|
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ def install_moonraker_packages() -> None:
|
|||||||
if not moonraker_deps:
|
if not moonraker_deps:
|
||||||
raise ValueError("Error reading Moonraker dependencies!")
|
raise ValueError("Error reading Moonraker dependencies!")
|
||||||
|
|
||||||
check_install_dependencies(moonraker_deps)
|
check_install_dependencies({*moonraker_deps})
|
||||||
|
|
||||||
|
|
||||||
def install_moonraker_polkit() -> None:
|
def install_moonraker_polkit() -> None:
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ def install_oe_dependencies() -> None:
|
|||||||
if not oe_deps:
|
if not oe_deps:
|
||||||
raise ValueError("Error reading OctoEverywhere dependencies!")
|
raise ValueError("Error reading OctoEverywhere dependencies!")
|
||||||
|
|
||||||
check_install_dependencies(oe_deps)
|
check_install_dependencies({*oe_deps})
|
||||||
install_python_requirements(OE_ENV_DIR, OE_REQ_FILE)
|
install_python_requirements(OE_ENV_DIR, OE_REQ_FILE)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ def install_client(client: BaseWebClient) -> None:
|
|||||||
)
|
)
|
||||||
valid_port = is_valid_port(port, ports_in_use)
|
valid_port = is_valid_port(port, ports_in_use)
|
||||||
|
|
||||||
check_install_dependencies(["nginx"])
|
check_install_dependencies({"nginx"})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
download_client(client)
|
download_client(client)
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ class ObicoExtension(BaseExtension):
|
|||||||
# install dependencies
|
# install dependencies
|
||||||
script = OBICO_DIR.joinpath("install.sh")
|
script = OBICO_DIR.joinpath("install.sh")
|
||||||
package_list = parse_packages_from_file(script)
|
package_list = parse_packages_from_file(script)
|
||||||
check_install_dependencies(package_list)
|
check_install_dependencies({*package_list})
|
||||||
|
|
||||||
# create virtualenv
|
# create virtualenv
|
||||||
create_python_venv(OBICO_ENV_DIR)
|
create_python_venv(OBICO_ENV_DIR)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class PrettyGcodeExtension(BaseExtension):
|
|||||||
allow_go_back=True,
|
allow_go_back=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
check_install_dependencies(["nginx"])
|
check_install_dependencies({"nginx"})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# remove any existing pgc dir
|
# remove any existing pgc dir
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class TelegramBotExtension(BaseExtension):
|
|||||||
# install dependencies
|
# install dependencies
|
||||||
script = TG_BOT_DIR.joinpath("scripts/install.sh")
|
script = TG_BOT_DIR.joinpath("scripts/install.sh")
|
||||||
package_list = parse_packages_from_file(script)
|
package_list = parse_packages_from_file(script)
|
||||||
check_install_dependencies(package_list)
|
check_install_dependencies({*package_list})
|
||||||
|
|
||||||
# create virtualenv
|
# create virtualenv
|
||||||
create_python_venv(TG_BOT_ENV)
|
create_python_venv(TG_BOT_ENV)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from __future__ import annotations
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Literal, Optional, Type
|
from typing import Dict, List, Literal, Optional, Set, Type
|
||||||
|
|
||||||
from components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from core.constants import (
|
from core.constants import (
|
||||||
@@ -47,17 +47,23 @@ def get_current_date() -> Dict[Literal["date", "time"], str]:
|
|||||||
return {"date": date, "time": time}
|
return {"date": date, "time": time}
|
||||||
|
|
||||||
|
|
||||||
def check_install_dependencies(deps: List[str] | None = None) -> None:
|
def check_install_dependencies(
|
||||||
|
deps: Set[str] | None = None, include_global: bool = True
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Common helper method to check if dependencies are installed
|
Common helper method to check if dependencies are installed
|
||||||
and if not, install them automatically |
|
and if not, install them automatically |
|
||||||
|
:param include_global: Wether to include the global dependencies or not
|
||||||
:param deps: List of strings of package names to check if installed
|
:param deps: List of strings of package names to check if installed
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
if deps is None:
|
if deps is None:
|
||||||
deps = []
|
deps = set()
|
||||||
|
|
||||||
requirements = check_package_install({*GLOBAL_DEPS, *deps})
|
if include_global:
|
||||||
|
deps.update(GLOBAL_DEPS)
|
||||||
|
|
||||||
|
requirements = check_package_install(deps)
|
||||||
if requirements:
|
if requirements:
|
||||||
Logger.print_status("Installing dependencies ...")
|
Logger.print_status("Installing dependencies ...")
|
||||||
Logger.print_info("The following packages need installation:")
|
Logger.print_info("The following packages need installation:")
|
||||||
|
|||||||
Reference in New Issue
Block a user