From f874709431e730be8f95120d8f04e549a09ded36 Mon Sep 17 00:00:00 2001 From: dw-0 Date: Thu, 13 Mar 2025 17:57:31 +0100 Subject: [PATCH] chore: fix formatting/wording also add a quick check if the klipper env exists Signed-off-by: Dominik Willner --- kiauh/components/klipper/klipper_utils.py | 33 +++++++++++++++-------- kiauh/core/menus/advanced_menu.py | 4 +-- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/kiauh/components/klipper/klipper_utils.py b/kiauh/components/klipper/klipper_utils.py index 08f1fc4..6c75c68 100644 --- a/kiauh/components/klipper/klipper_utils.py +++ b/kiauh/components/klipper/klipper_utils.py @@ -43,7 +43,11 @@ from utils.common import check_install_dependencies, get_install_status from utils.fs_utils import check_file_exist from utils.input_utils import get_confirm, get_number_input, get_string_input from utils.instance_utils import get_instances -from utils.sys_utils import cmd_sysctl_service, parse_packages_from_file, install_python_packages +from utils.sys_utils import ( + cmd_sysctl_service, + install_python_packages, + parse_packages_from_file, +) def get_klipper_status() -> ComponentStatus: @@ -214,22 +218,29 @@ def install_klipper_packages() -> None: def install_input_shaper_deps() -> None: + if not KLIPPER_ENV_DIR.exists(): + Logger.print_warn("Required Klipper python environment not found!") + return + Logger.print_dialog( DialogType.CUSTOM, [ "Resonance measurements and shaper auto-calibration require additional " - "software dependencies not installed by default. " - "If you agree, the following additional debian packages will be installed:", + "software dependencies which are not installed by default. " + "If you agree, the following additional system packages will be installed:", + "● python3-numpy", + "● python3-matplotlib", + "● libatlas-base-dev", + "● libopenblas-dev", "\n\n", - "python3-numpy python3-matplotlib libatlas-base-dev libopenblas-dev", - "\n\n", - "And also the following pip package will be installed: " - "\n\n", - "numpy", + "Also, the following Python package will be installed:", + "● numpy", ], custom_title="Install Input Shaper Dependencies", ) - if not get_confirm("Do you want to install required packages?", default_choice=False): + if not get_confirm( + "Do you want to install the required packages?", default_choice=False + ): return apt_deps = ( @@ -239,7 +250,7 @@ def install_input_shaper_deps() -> None: "libopenblas-dev", ) check_install_dependencies({*apt_deps}) - + py_deps = ("numpy",) - + install_python_packages(KLIPPER_ENV_DIR, {*py_deps}) diff --git a/kiauh/core/menus/advanced_menu.py b/kiauh/core/menus/advanced_menu.py index 33e9fa5..7311d39 100644 --- a/kiauh/core/menus/advanced_menu.py +++ b/kiauh/core/menus/advanced_menu.py @@ -67,8 +67,8 @@ class AdvancedMenu(BaseMenu): ║ 3) [Build + Flash] │ ║ ║ 4) [Get MCU ID] │ System: ║ ║ │ 8) [Change hostname] ║ - ║ Extra dependencies: │ ║ - ║ 5) [Input shaper] │ ║ + ║ Extra Dependencies: │ ║ + ║ 5) [Input Shaper] │ ║ ╟───────────────────────────┴───────────────────────────╢ """ )[1:]