mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-26 17:23:35 +05:00
Compare commits
23 Commits
84e5359895
...
v6.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70055e891e | ||
|
|
e3a0a9dec0 | ||
|
|
1cf81377ee | ||
|
|
aa4ea99c5c | ||
|
|
20ffc82a04 | ||
|
|
0becf9d574 | ||
|
|
ed1bfcdeb4 | ||
|
|
033916216c | ||
|
|
d8f47c0960 | ||
|
|
4978f22101 | ||
|
|
8330f90b56 | ||
|
|
a58288e7e3 | ||
|
|
d9626adc98 | ||
|
|
b02df9a1e0 | ||
|
|
243ea6582a | ||
|
|
a63cf8c9d9 | ||
|
|
425d86a12f | ||
|
|
1b5691f2f5 | ||
|
|
dc026a7a2b | ||
|
|
a8a73249a5 | ||
|
|
ec3f93eeda | ||
|
|
4cf523a758 | ||
|
|
1d06bf76f3 |
@@ -167,7 +167,7 @@ def start_flash_process(flash_options: FlashOptions) -> None:
|
||||
if rc != 0:
|
||||
raise Exception(f"Flashing failed with returncode: {rc}")
|
||||
else:
|
||||
Logger.print_ok("Flashing successfull!", start="\n", end="\n\n")
|
||||
Logger.print_ok("Flashing successful!", start="\n", end="\n\n")
|
||||
|
||||
except (Exception, CalledProcessError):
|
||||
Logger.print_error("Flashing failed!", start="\n")
|
||||
|
||||
@@ -147,16 +147,22 @@ class KlipperBuildFirmwareMenu(BaseMenu):
|
||||
)
|
||||
|
||||
def set_options(self) -> None:
|
||||
self.input_label_txt = "Press ENTER to install dependencies"
|
||||
self.default_option = Option(method=self.install_missing_deps)
|
||||
|
||||
def run(self):
|
||||
# immediately start the build process if all dependencies are met
|
||||
if len(self.missing_deps) == 0:
|
||||
self.input_label_txt = "Press ENTER to continue"
|
||||
self.default_option = Option(method=self.start_build_process)
|
||||
self.start_build_process()
|
||||
else:
|
||||
self.input_label_txt = "Press ENTER to install dependencies"
|
||||
self.default_option = Option(method=self.install_missing_deps)
|
||||
super().run()
|
||||
|
||||
def print_menu(self) -> None:
|
||||
txt = Color.apply("Dependencies are missing!", Color.RED)
|
||||
menu = textwrap.dedent(
|
||||
"""
|
||||
f"""
|
||||
╟───────────────────────────────────────────────────────╢
|
||||
║ {txt:^62} ║
|
||||
╟───────────────────────────────────────────────────────╢
|
||||
║ The following dependencies are required: ║
|
||||
║ ║
|
||||
@@ -170,16 +176,8 @@ class KlipperBuildFirmwareMenu(BaseMenu):
|
||||
padding = 40 - len(d) + len(status) + (len(status_ok) - len(status))
|
||||
d = Color.apply(f"● {d}", Color.CYAN)
|
||||
menu += f"║ {d}{status:>{padding}} ║\n"
|
||||
|
||||
menu += "║ ║\n"
|
||||
|
||||
color = Color.GREEN if len(self.missing_deps) == 0 else Color.RED
|
||||
txt = (
|
||||
"All dependencies are met!"
|
||||
if len(self.missing_deps) == 0
|
||||
else "Dependencies are missing!"
|
||||
)
|
||||
|
||||
menu += f"║ {Color.apply(txt, color):<62} ║\n"
|
||||
menu += "╟───────────────────────────────────────────────────────╢\n"
|
||||
|
||||
print(menu, end="")
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
# ======================================================================= #
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
from typing import List
|
||||
|
||||
@@ -31,6 +30,7 @@ from components.moonraker.moonraker_dialogs import print_moonraker_overview
|
||||
from components.moonraker.moonraker_utils import (
|
||||
backup_moonraker_dir,
|
||||
create_example_moonraker_conf,
|
||||
parse_sysdeps_file,
|
||||
)
|
||||
from components.webui_client.client_utils import (
|
||||
enable_mainsail_remotemode,
|
||||
@@ -53,6 +53,7 @@ from utils.sys_utils import (
|
||||
cmd_sysctl_manage,
|
||||
cmd_sysctl_service,
|
||||
create_python_venv,
|
||||
get_distro_info,
|
||||
install_python_requirements,
|
||||
parse_packages_from_file,
|
||||
)
|
||||
@@ -157,9 +158,37 @@ def install_moonraker_packages() -> None:
|
||||
moonraker_deps = []
|
||||
|
||||
if MOONRAKER_DEPS_JSON_FILE.exists():
|
||||
with open(MOONRAKER_DEPS_JSON_FILE, "r") as deps:
|
||||
moonraker_deps = json.load(deps).get("debian", [])
|
||||
Logger.print_status(
|
||||
f"Parsing system dependencies from {MOONRAKER_DEPS_JSON_FILE.name} ..."
|
||||
)
|
||||
parsed_sysdeps = parse_sysdeps_file(MOONRAKER_DEPS_JSON_FILE)
|
||||
distro_name, distro_version = get_distro_info()
|
||||
|
||||
Logger.print_info(f"Distro name: {distro_name}")
|
||||
Logger.print_info(f"Distro version: {distro_version}")
|
||||
|
||||
for dep in parsed_sysdeps.get(distro_name, []):
|
||||
pkg = dep[0].strip()
|
||||
comparator = dep[1].strip()
|
||||
req_version = dep[2].strip()
|
||||
|
||||
comparisons = {
|
||||
"": lambda x, y: True,
|
||||
"<": lambda x, y: x < y,
|
||||
">": lambda x, y: x > y,
|
||||
"<=": lambda x, y: x <= y,
|
||||
">=": lambda x, y: x >= y,
|
||||
"==": lambda x, y: x == y,
|
||||
"!=": lambda x, y: x != y,
|
||||
}
|
||||
|
||||
if comparisons[comparator](float(distro_version), float(req_version or 0)):
|
||||
moonraker_deps.append(pkg)
|
||||
|
||||
elif MOONRAKER_INSTALL_SCRIPT.exists():
|
||||
Logger.print_status(
|
||||
f"Parsing system dependencies from {MOONRAKER_INSTALL_SCRIPT.name} ..."
|
||||
)
|
||||
moonraker_deps = parse_packages_from_file(MOONRAKER_INSTALL_SCRIPT)
|
||||
|
||||
if not moonraker_deps:
|
||||
|
||||
@@ -6,9 +6,11 @@
|
||||
# #
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
# ======================================================================= #
|
||||
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
from typing import Dict, List, Optional
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
from components.moonraker import (
|
||||
MODULE_PATH,
|
||||
@@ -138,3 +140,34 @@ def backup_moonraker_db_dir() -> None:
|
||||
bm.backup_directory(
|
||||
name, source=instance.db_dir, target=MOONRAKER_DB_BACKUP_DIR
|
||||
)
|
||||
|
||||
|
||||
# This function is from sync_dependencies.py script from the Moonraker project on GitHub:
|
||||
# https://github.com/Arksine/moonraker/blob/master/scripts/sync_dependencies.py
|
||||
# Thanks to Arksine for his work on this project!
|
||||
def parse_sysdeps_file(sysdeps_file: Path) -> Dict[str, List[Tuple[str, str, str]]]:
|
||||
"""
|
||||
Parses the system dependencies file and returns a dictionary with the parsed dependencies.
|
||||
:param sysdeps_file: The path to the system dependencies file.
|
||||
:return: A dictionary with the parsed dependencies in the format {distro: [(package, comparator, version)]}.
|
||||
"""
|
||||
base_deps: Dict[str, List[str]] = json.loads(sysdeps_file.read_bytes())
|
||||
parsed_deps: Dict[str, List[Tuple[str, str, str]]] = {}
|
||||
|
||||
for distro, pkgs in base_deps.items():
|
||||
parsed_deps[distro] = []
|
||||
for dep in pkgs:
|
||||
parts = dep.split(";", maxsplit=1)
|
||||
if len(parts) == 1:
|
||||
parsed_deps[distro].append((dep.strip(), "", ""))
|
||||
else:
|
||||
pkg_name = parts[0].strip()
|
||||
dep_parts = re.split(r"(==|!=|<=|>=|<|>)", parts[1].strip())
|
||||
comp_var = dep_parts[0].strip().lower()
|
||||
if len(dep_parts) != 3 or comp_var != "distro_version":
|
||||
continue
|
||||
operator = dep_parts[1].strip()
|
||||
req_version = dep_parts[2].strip()
|
||||
parsed_deps[distro].append((pkg_name, operator, req_version))
|
||||
|
||||
return parsed_deps
|
||||
|
||||
@@ -31,7 +31,7 @@ def change_system_hostname() -> None:
|
||||
"http://<hostname>.local",
|
||||
"\n\n",
|
||||
"Example: If you set your hostname to 'my-printer', you can access an "
|
||||
"installed webinterface by tyoing 'http://my-printer.local' in the "
|
||||
"installed webinterface by typing 'http://my-printer.local' in the "
|
||||
"browser.",
|
||||
],
|
||||
custom_title="CHANGE SYSTEM HOSTNAME",
|
||||
|
||||
@@ -19,7 +19,7 @@ import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
from subprocess import DEVNULL, PIPE, CalledProcessError, Popen, check_output, run
|
||||
from typing import List, Literal, Set
|
||||
from typing import List, Literal, Set, Tuple
|
||||
|
||||
from core.constants import SYSTEMD
|
||||
from core.logger import Logger
|
||||
@@ -539,3 +539,32 @@ def get_service_file_path(instance_type: type, suffix: str) -> Path:
|
||||
file_path: Path = SYSTEMD.joinpath(f"{name}.service")
|
||||
|
||||
return file_path
|
||||
|
||||
|
||||
def get_distro_info() -> Tuple[str, str]:
|
||||
distro_info: str = check_output(["cat", "/etc/os-release"]).decode().strip()
|
||||
|
||||
if not distro_info:
|
||||
raise ValueError("Error reading distro info!")
|
||||
|
||||
distro_id: str = ""
|
||||
distro_id_like: str = ""
|
||||
distro_version: str = ""
|
||||
|
||||
for line in distro_info.split("\n"):
|
||||
if line.startswith("ID="):
|
||||
distro_id = line.split("=")[1].strip('"').strip()
|
||||
if line.startswith("ID_LIKE="):
|
||||
distro_id_like = line.split("=")[1].strip('"').strip()
|
||||
if line.startswith("VERSION_ID="):
|
||||
distro_version = line.split("=")[1].strip('"').strip()
|
||||
|
||||
if distro_id == "raspbian":
|
||||
distro_id = distro_id_like
|
||||
|
||||
if not distro_id:
|
||||
raise ValueError("Error reading distro id!")
|
||||
if not distro_version:
|
||||
raise ValueError("Error reading distro version!")
|
||||
|
||||
return distro_id.lower(), distro_version
|
||||
|
||||
@@ -16,6 +16,7 @@ trusted_clients:
|
||||
cors_domains:
|
||||
*.lan
|
||||
*.local
|
||||
*.internal
|
||||
*://localhost
|
||||
*://localhost:*
|
||||
*://my.mainsail.xyz
|
||||
|
||||
Reference in New Issue
Block a user