mirror of
https://github.com/dw-0/kiauh.git
synced 2026-05-05 00:38:15 +05:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea1b794afd | |||
| 647a7d9400 | |||
| aa0609d143 | |||
| 2175bd55f9 | |||
| a935e67431 | |||
| 2f41e52189 | |||
| 757344128a | |||
| 7ca08f9b30 | |||
| 308079a821 | |||
| 09a5d96b63 | |||
| 1f9d4c823a | |||
| c8df9427b3 | |||
| 5414aba299 | |||
| 80948edbb4 | |||
| a455edba93 | |||
| 810ab3a2fa | |||
| 6c9a78496a | |||
| 123ccde378 | |||
| 45fde808d2 | |||
| 8ba134f574 | |||
| f951936b20 | |||
| 657d919378 | |||
| 24c9b9daa9 | |||
| 4c511017f1 |
@@ -7,6 +7,7 @@
|
|||||||
*.tmp
|
*.tmp
|
||||||
__pycache__
|
__pycache__
|
||||||
.kiauh-env
|
.kiauh-env
|
||||||
|
.venv
|
||||||
*.code-workspace
|
*.code-workspace
|
||||||
*.iml
|
*.iml
|
||||||
kiauh.cfg
|
kiauh.cfg
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
# AGENTS.md - KIAUH Development Guide
|
||||||
|
|
||||||
|
## Project Overview
|
||||||
|
|
||||||
|
KIAUH (Klipper Installation And Update Helper) is a Python-based installation script for Klipper 3D printer firmware and related components written in Python 3.8+.
|
||||||
|
|
||||||
|
## Running KIAUH
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./kiauh.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
**Important:** Must NOT run as root. The script will exit if EUID is 0.
|
||||||
|
|
||||||
|
## Development Commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install dev dependencies
|
||||||
|
pip install -r requirements-dev.txt
|
||||||
|
|
||||||
|
# Lint (ruff)
|
||||||
|
ruff check .
|
||||||
|
|
||||||
|
# Format
|
||||||
|
ruff format .
|
||||||
|
|
||||||
|
# Typecheck
|
||||||
|
mypy kiauh
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
pytest
|
||||||
|
|
||||||
|
# Run specific test file
|
||||||
|
pytest kiauh/core/simple_config_parser/tests/public_api/test_options_api.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
- New tests should be placed near their corresponding components/modules (e.g., `kiauh/components/klipper/*/test_*.py`)
|
||||||
|
- Always use a `tests/` subdirectory
|
||||||
|
- Existing pytest setup in `kiauh/core/simple_config_parser/tests/` serves as reference
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
- `kiauh.sh` - Bash entry point, sets PYTHONPATH and calls main.py
|
||||||
|
- `kiauh/main.py` - Python entry point
|
||||||
|
- `kiauh/core/` - Core functionality (menus, services, settings, types)
|
||||||
|
- `kiauh/components/` - Klipper components (klipper, moonraker, webui_client, etc.)
|
||||||
|
- `kiauh/extensions/` - Extension system for optional addons (obico, octoprint, spoolman, etc.)
|
||||||
|
- `kiauh/core/simple_config_parser/` - Custom INI-style config parser for Klipper configs
|
||||||
|
- `kiauh/core/simple_config_parser/src/simple_config_parser/` - Submodule (git subtree)
|
||||||
|
|
||||||
|
## Key Quirks
|
||||||
|
|
||||||
|
1. **Python version:** Requires Python 3.8+ (checked in kiauh.sh)
|
||||||
|
2. **Config files:** KIAUH uses `kiauh.cfg` in project root (not .ini format - it's parsed by simple_config_parser)
|
||||||
|
3. **Submodule:** `kiauh/core/simple_config_parser/` is a git subtree, not a submodule
|
||||||
|
4. **Branch check:** KIAUH only checks for updates on master branch (not develop)
|
||||||
|
5. **Target:** Designed to run on Raspberry Pi OS / Debian-based distros
|
||||||
|
|
||||||
|
## Code Style
|
||||||
|
|
||||||
|
- 4-space indentation
|
||||||
|
- 88 character line length
|
||||||
|
- Double quotes
|
||||||
|
- LF line endings
|
||||||
|
- Type hints required (mypy checks)
|
||||||
|
- Ruff with I (isort) enabled
|
||||||
@@ -143,7 +143,7 @@ changes!**
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th><h3><a href="https://github.com/fluidd-core/fluidd">Fluidd</a></h3></th>
|
<th><h3><a href="https://github.com/fluidd-core/fluidd">Fluidd</a></h3></th>
|
||||||
<th><h3><a href="https://github.com/jordanruthe/KlipperScreen">KlipperScreen</a></h3></th>
|
<th><h3><a href="https://github.com/KlipperScreen/KlipperScreen">KlipperScreen</a></h3></th>
|
||||||
<th><h3><a href="https://github.com/OctoPrint/OctoPrint">OctoPrint</a></h3></th>
|
<th><h3><a href="https://github.com/OctoPrint/OctoPrint">OctoPrint</a></h3></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -153,7 +153,7 @@ changes!**
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>by <a href="https://github.com/fluidd-core">fluidd-core</a></th>
|
<th>by <a href="https://github.com/fluidd-core">fluidd-core</a></th>
|
||||||
<th>by <a href="https://github.com/jordanruthe">jordanruthe</a></th>
|
<th>by <a href="https://github.com/alfrix">alfrix</a></th>
|
||||||
<th>by <a href="https://github.com/OctoPrint">OctoPrint</a></th>
|
<th>by <a href="https://github.com/OctoPrint">OctoPrint</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
#=======================================================================#
|
#=======================================================================#
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -15,18 +15,30 @@ clear -x
|
|||||||
# make sure we have the correct permissions while running the script
|
# make sure we have the correct permissions while running the script
|
||||||
umask 022
|
umask 022
|
||||||
|
|
||||||
|
# gets the path where this script is located
|
||||||
|
KIAUH_SRCDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
|
||||||
|
|
||||||
|
# colors
|
||||||
|
white="\033[37m"
|
||||||
|
cyan="\033[96m"
|
||||||
|
red="\033[91m"
|
||||||
|
yellow="\033[93m"
|
||||||
|
green="\033[92m"
|
||||||
|
|
||||||
#===================================================#
|
#===================================================#
|
||||||
#=================== UPDATE KIAUH ==================#
|
#=================== UPDATE KIAUH ==================#
|
||||||
#===================================================#
|
#===================================================#
|
||||||
|
|
||||||
function update_kiauh() {
|
function update_kiauh() {
|
||||||
status_msg "Updating KIAUH ..."
|
echo "Updating KIAUH ..."
|
||||||
|
|
||||||
cd "${KIAUH_SRCDIR}"
|
cd "${KIAUH_SRCDIR}"
|
||||||
git reset --hard && git pull
|
git reset --hard && git pull
|
||||||
|
|
||||||
ok_msg "Update complete! Please restart KIAUH."
|
echo "Update complete! Restarting..."
|
||||||
exit 0
|
sleep 1
|
||||||
|
exec "$0" "$@" # restarts the script
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#===================================================#
|
#===================================================#
|
||||||
@@ -65,16 +77,18 @@ function kiauh_update_dialog() {
|
|||||||
echo -e "\-------------------------------------------------------/"
|
echo -e "\-------------------------------------------------------/"
|
||||||
|
|
||||||
local yn
|
local yn
|
||||||
read -p "${cyan}###### Do you want to update now? (Y/n):${white} " yn
|
echo -ne "${cyan}###### Do you want to update now? (Y/n):${white} "
|
||||||
|
read yn
|
||||||
while true; do
|
while true; do
|
||||||
case "${yn}" in
|
case "${yn}" in
|
||||||
Y|y|Yes|yes|"")
|
Y|y|Yes|yes|"")
|
||||||
do_action "update_kiauh"
|
update_kiauh
|
||||||
break;;
|
break;;
|
||||||
N|n|No|no)
|
N|n|No|no)
|
||||||
break;;
|
break;;
|
||||||
*)
|
*)
|
||||||
deny_action "kiauh_update_dialog";;
|
echo -e "${red}Invalid input. Please try again.${white}"
|
||||||
|
kiauh_update_dialog;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -47,7 +47,7 @@ from utils.sys_utils import (
|
|||||||
|
|
||||||
def install_crowsnest() -> None:
|
def install_crowsnest() -> None:
|
||||||
# Step 1: Clone crowsnest repo
|
# Step 1: Clone crowsnest repo
|
||||||
git_clone_wrapper(CROWSNEST_REPO, CROWSNEST_DIR, "master")
|
git_clone_wrapper(CROWSNEST_REPO, CROWSNEST_DIR)
|
||||||
|
|
||||||
# Step 2: Install dependencies
|
# Step 2: Install dependencies
|
||||||
check_install_dependencies({"make"})
|
check_install_dependencies({"make"})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -34,7 +34,7 @@ from core.constants import CURRENT_USER
|
|||||||
from core.instance_manager.base_instance import SUFFIX_BLACKLIST
|
from core.instance_manager.base_instance import SUFFIX_BLACKLIST
|
||||||
from core.logger import DialogType, Logger
|
from core.logger import DialogType, Logger
|
||||||
from core.services.backup_service import BackupService
|
from core.services.backup_service import BackupService
|
||||||
from core.submodules.simple_config_parser.src.simple_config_parser.simple_config_parser import (
|
from core.simple_config_parser.simple_config_parser import (
|
||||||
SimpleConfigParser,
|
SimpleConfigParser,
|
||||||
)
|
)
|
||||||
from core.types.component_status import ComponentStatus
|
from core.types.component_status import ComponentStatus
|
||||||
@@ -113,7 +113,7 @@ def check_user_groups() -> None:
|
|||||||
|
|
||||||
if not get_confirm(f"Add user '{CURRENT_USER}' to group(s) now?"):
|
if not get_confirm(f"Add user '{CURRENT_USER}' to group(s) now?"):
|
||||||
log = "Skipped adding user to required groups. You might encounter issues."
|
log = "Skipped adding user to required groups. You might encounter issues."
|
||||||
Logger.warn(log)
|
Logger.print_warn(log)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -236,9 +236,11 @@ class KlipperSelectMcuConnectionMenu(BaseMenu):
|
|||||||
if len(self.flash_options.mcu_list) < 1:
|
if len(self.flash_options.mcu_list) < 1:
|
||||||
Logger.print_warn("No MCUs found!")
|
Logger.print_warn("No MCUs found!")
|
||||||
Logger.print_warn("Make sure they are connected and repeat this step.")
|
Logger.print_warn("Make sure they are connected and repeat this step.")
|
||||||
|
time.sleep(3)
|
||||||
|
return
|
||||||
|
|
||||||
# if standalone is True, we only display the MCUs to the user and return
|
# if standalone is True, we only display the MCUs to the user and return
|
||||||
if self.__standalone and len(self.flash_options.mcu_list) > 0:
|
if self.__standalone:
|
||||||
Logger.print_ok("The following MCUs were found:", prefix=False)
|
Logger.print_ok("The following MCUs were found:", prefix=False)
|
||||||
for i, mcu in enumerate(self.flash_options.mcu_list):
|
for i, mcu in enumerate(self.flash_options.mcu_list):
|
||||||
print(f" ● MCU #{i}: {Color.CYAN}{mcu}{Color.RST}")
|
print(f" ● MCU #{i}: {Color.CYAN}{mcu}{Color.RST}")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -25,7 +25,7 @@ from components.moonraker import (
|
|||||||
from core.constants import CURRENT_USER
|
from core.constants import CURRENT_USER
|
||||||
from core.instance_manager.base_instance import BaseInstance
|
from core.instance_manager.base_instance import BaseInstance
|
||||||
from core.logger import Logger
|
from core.logger import Logger
|
||||||
from core.submodules.simple_config_parser.src.simple_config_parser.simple_config_parser import (
|
from core.simple_config_parser.simple_config_parser import (
|
||||||
SimpleConfigParser,
|
SimpleConfigParser,
|
||||||
)
|
)
|
||||||
from utils.fs_utils import create_folders
|
from utils.fs_utils import create_folders
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -25,7 +25,7 @@ from components.moonraker.utils.sysdeps_parser import SysDepsParser
|
|||||||
from components.webui_client.base_data import BaseWebClient
|
from components.webui_client.base_data import BaseWebClient
|
||||||
from core.logger import Logger
|
from core.logger import Logger
|
||||||
from core.services.backup_service import BackupService
|
from core.services.backup_service import BackupService
|
||||||
from core.submodules.simple_config_parser.src.simple_config_parser.simple_config_parser import (
|
from core.simple_config_parser.simple_config_parser import (
|
||||||
SimpleConfigParser,
|
SimpleConfigParser,
|
||||||
)
|
)
|
||||||
from core.types.component_status import ComponentStatus
|
from core.types.component_status import ComponentStatus
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
|
|
||||||
from typing import List
|
from typing import List, Optional
|
||||||
|
|
||||||
from components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
@@ -27,6 +27,7 @@ def run_client_config_removal(
|
|||||||
client_config: BaseWebClientConfig,
|
client_config: BaseWebClientConfig,
|
||||||
kl_instances: List[Klipper],
|
kl_instances: List[Klipper],
|
||||||
mr_instances: List[Moonraker],
|
mr_instances: List[Moonraker],
|
||||||
|
svc: Optional[BackupService] = None,
|
||||||
) -> Message:
|
) -> Message:
|
||||||
completion_msg = Message(
|
completion_msg = Message(
|
||||||
title=f"{client_config.display_name} Removal Process completed",
|
title=f"{client_config.display_name} Removal Process completed",
|
||||||
@@ -36,12 +37,15 @@ def run_client_config_removal(
|
|||||||
if run_remove_routines(client_config.config_dir):
|
if run_remove_routines(client_config.config_dir):
|
||||||
completion_msg.text.append(f"● {client_config.display_name} removed")
|
completion_msg.text.append(f"● {client_config.display_name} removed")
|
||||||
|
|
||||||
BackupService().backup_printer_config_dir()
|
if svc is None:
|
||||||
|
svc = BackupService()
|
||||||
|
|
||||||
|
svc.backup_moonraker_conf()
|
||||||
completion_msg = remove_moonraker_config_section(
|
completion_msg = remove_moonraker_config_section(
|
||||||
completion_msg, client_config, mr_instances
|
completion_msg, client_config, mr_instances
|
||||||
)
|
)
|
||||||
|
|
||||||
|
svc.backup_printer_cfg()
|
||||||
completion_msg = remove_printer_config_section(
|
completion_msg = remove_printer_config_section(
|
||||||
completion_msg, client_config, kl_instances
|
completion_msg, client_config, kl_instances
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -41,6 +41,7 @@ def run_client_removal(
|
|||||||
)
|
)
|
||||||
mr_instances: List[Moonraker] = get_instances(Moonraker)
|
mr_instances: List[Moonraker] = get_instances(Moonraker)
|
||||||
kl_instances: List[Klipper] = get_instances(Klipper)
|
kl_instances: List[Klipper] = get_instances(Klipper)
|
||||||
|
svc = BackupService()
|
||||||
|
|
||||||
if backup_config:
|
if backup_config:
|
||||||
version = ""
|
version = ""
|
||||||
@@ -49,7 +50,6 @@ def run_client_removal(
|
|||||||
with open(src.joinpath(".version"), "r") as v:
|
with open(src.joinpath(".version"), "r") as v:
|
||||||
version = v.readlines()[0]
|
version = v.readlines()[0]
|
||||||
|
|
||||||
svc = BackupService()
|
|
||||||
target_path = svc.backup_root.joinpath(f"{client.client_dir.name}_{version}")
|
target_path = svc.backup_root.joinpath(f"{client.client_dir.name}_{version}")
|
||||||
success = svc.backup_file(
|
success = svc.backup_file(
|
||||||
source_path=client.config_file,
|
source_path=client.config_file,
|
||||||
@@ -67,7 +67,7 @@ def run_client_removal(
|
|||||||
if remove_client_nginx_logs(client, kl_instances):
|
if remove_client_nginx_logs(client, kl_instances):
|
||||||
completion_msg.text.append("● NGINX logs removed")
|
completion_msg.text.append("● NGINX logs removed")
|
||||||
|
|
||||||
BackupService().backup_moonraker_conf()
|
svc.backup_moonraker_conf()
|
||||||
section = f"update_manager {client_name}"
|
section = f"update_manager {client_name}"
|
||||||
handled_instances: List[Moonraker] = remove_config_section(
|
handled_instances: List[Moonraker] = remove_config_section(
|
||||||
section, mr_instances
|
section, mr_instances
|
||||||
@@ -83,6 +83,7 @@ def run_client_removal(
|
|||||||
client.client_config,
|
client.client_config,
|
||||||
kl_instances,
|
kl_instances,
|
||||||
mr_instances,
|
mr_instances,
|
||||||
|
svc,
|
||||||
)
|
)
|
||||||
if cfg_completion_msg.color == Color.GREEN:
|
if cfg_completion_msg.color == Color.GREEN:
|
||||||
completion_msg.text.extend(cfg_completion_msg.text[1:])
|
completion_msg.text.extend(cfg_completion_msg.text[1:])
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -33,7 +33,7 @@ from core.constants import (
|
|||||||
from core.logger import Logger
|
from core.logger import Logger
|
||||||
from core.services.backup_service import BackupService
|
from core.services.backup_service import BackupService
|
||||||
from core.settings.kiauh_settings import KiauhSettings, WebUiSettings
|
from core.settings.kiauh_settings import KiauhSettings, WebUiSettings
|
||||||
from core.submodules.simple_config_parser.src.simple_config_parser.simple_config_parser import (
|
from core.simple_config_parser.simple_config_parser import (
|
||||||
SimpleConfigParser,
|
SimpleConfigParser,
|
||||||
)
|
)
|
||||||
from core.types.color import Color
|
from core.types.color import Color
|
||||||
@@ -78,10 +78,10 @@ def get_current_client_config() -> str:
|
|||||||
installed = [c for c in clients if c.client_config.config_dir.exists()]
|
installed = [c for c in clients if c.client_config.config_dir.exists()]
|
||||||
|
|
||||||
if not installed:
|
if not installed:
|
||||||
return Color.apply("-", Color.CYAN)
|
return str(Color.apply("-", Color.CYAN))
|
||||||
elif len(installed) == 1:
|
elif len(installed) == 1:
|
||||||
cfg = installed[0].client_config
|
cfg = installed[0].client_config
|
||||||
return Color.apply(cfg.display_name, Color.CYAN)
|
return str(Color.apply(cfg.display_name, Color.CYAN))
|
||||||
|
|
||||||
# at this point, both client config folders exists, so we need to check
|
# at this point, both client config folders exists, so we need to check
|
||||||
# which are actually included in the printer.cfg of all klipper instances
|
# which are actually included in the printer.cfg of all klipper instances
|
||||||
@@ -100,18 +100,18 @@ def get_current_client_config() -> str:
|
|||||||
|
|
||||||
# if both are included in the same file, we have a potential conflict
|
# if both are included in the same file, we have a potential conflict
|
||||||
if includes_mainsail and includes_fluidd:
|
if includes_mainsail and includes_fluidd:
|
||||||
return Color.apply("Conflict", Color.YELLOW)
|
return str(Color.apply("Conflict", Color.YELLOW))
|
||||||
|
|
||||||
if not mainsail_includes and not fluidd_includes:
|
if not mainsail_includes and not fluidd_includes:
|
||||||
# there are no includes at all, even though the client config folders exist
|
# there are no includes at all, even though the client config folders exist
|
||||||
return Color.apply("-", Color.CYAN)
|
return str(Color.apply("-", Color.CYAN))
|
||||||
elif len(fluidd_includes) > len(mainsail_includes):
|
elif len(fluidd_includes) > len(mainsail_includes):
|
||||||
# there are more instances that include fluidd than mainsail
|
# there are more instances that include fluidd than mainsail
|
||||||
return Color.apply(fluidd.client_config.display_name, Color.CYAN)
|
return str(Color.apply(fluidd.client_config.display_name, Color.CYAN))
|
||||||
else:
|
else:
|
||||||
# there are the same amount of non-conflicting includes for each config
|
# there are the same amount of non-conflicting includes for each config
|
||||||
# or more instances include mainsail than fluidd
|
# or more instances include mainsail than fluidd
|
||||||
return Color.apply(mainsail.client_config.display_name, Color.CYAN)
|
return str(Color.apply(mainsail.client_config.display_name, Color.CYAN))
|
||||||
|
|
||||||
|
|
||||||
def enable_mainsail_remotemode() -> None:
|
def enable_mainsail_remotemode() -> None:
|
||||||
@@ -152,10 +152,9 @@ def symlink_webui_nginx_log(
|
|||||||
def get_local_client_version(client: BaseWebClient) -> str | None:
|
def get_local_client_version(client: BaseWebClient) -> str | None:
|
||||||
relinfo_file = client.client_dir.joinpath("release_info.json")
|
relinfo_file = client.client_dir.joinpath("release_info.json")
|
||||||
version_file = client.client_dir.joinpath(".version")
|
version_file = client.client_dir.joinpath(".version")
|
||||||
default = "n/a"
|
|
||||||
|
|
||||||
if not client.client_dir.exists():
|
if not client.client_dir.exists():
|
||||||
return default
|
return None
|
||||||
|
|
||||||
# try to get version from release_info.json first
|
# try to get version from release_info.json first
|
||||||
if relinfo_file.is_file():
|
if relinfo_file.is_file():
|
||||||
@@ -177,11 +176,11 @@ def get_local_client_version(client: BaseWebClient) -> str | None:
|
|||||||
try:
|
try:
|
||||||
with open(version_file, "r") as f:
|
with open(version_file, "r") as f:
|
||||||
line = f.readline().strip()
|
line = f.readline().strip()
|
||||||
return line or default
|
return line or None
|
||||||
except OSError:
|
except OSError:
|
||||||
Logger.print_error("Unable to read '.version'")
|
Logger.print_error("Unable to read '.version'")
|
||||||
|
|
||||||
return default
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_remote_client_version(client: BaseWebClient) -> str | None:
|
def get_remote_client_version(client: BaseWebClient) -> str | None:
|
||||||
@@ -446,9 +445,9 @@ def get_client_port_selection(
|
|||||||
while True:
|
while True:
|
||||||
_type = "Reconfigure" if reconfigure else "Configure"
|
_type = "Reconfigure" if reconfigure else "Configure"
|
||||||
question = f"{_type} {client.display_name} for port"
|
question = f"{_type} {client.display_name} for port"
|
||||||
port_input = get_number_input(question, min_value=80, default=port)
|
port_input: int | None = get_number_input(question, min_value=80, default=port)
|
||||||
|
|
||||||
if port_input not in ports_in_use:
|
if port_input and port_input not in ports_in_use:
|
||||||
client_settings: WebUiSettings = settings[client.name]
|
client_settings: WebUiSettings = settings[client.name]
|
||||||
client_settings.port = port_input
|
client_settings.port = port_input
|
||||||
settings.save()
|
settings.save()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -97,7 +97,7 @@ class ClientInstallMenu(BaseMenu):
|
|||||||
self.message_service.set_message(message)
|
self.message_service.set_message(message)
|
||||||
|
|
||||||
def _get_current_port(self) -> int:
|
def _get_current_port(self) -> int:
|
||||||
curr_port = get_nginx_listen_port(self.client.nginx_config)
|
curr_port: int | None = get_nginx_listen_port(self.client.nginx_config)
|
||||||
if curr_port is None:
|
if curr_port is None:
|
||||||
# if the port is not found in the config file we use
|
# if the port is not found in the config file we use
|
||||||
# the default port from the kiauh settings as fallback
|
# the default port from the kiauh settings as fallback
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -95,8 +95,8 @@ class MainMenu(BaseMenu):
|
|||||||
status_data: ComponentStatus = status_fn(*args)
|
status_data: ComponentStatus = status_fn(*args)
|
||||||
code: int = status_data.status
|
code: int = status_data.status
|
||||||
status: StatusText = StatusMap[code]
|
status: StatusText = StatusMap[code]
|
||||||
owner: str = trunc_string(status_data.owner, 23)
|
owner: str = trunc_string(status_data.owner, 23) if status_data.owner else '-'
|
||||||
repo: str = trunc_string(status_data.repo, 23)
|
repo: str = trunc_string(status_data.repo, 23) if status_data.repo else '-'
|
||||||
instance_count: int = status_data.instances
|
instance_count: int = status_data.instances
|
||||||
|
|
||||||
count_txt: str = ""
|
count_txt: str = ""
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -100,11 +100,11 @@ class SettingsMenu(BaseMenu):
|
|||||||
def trim_repo_url(repo: str) -> str:
|
def trim_repo_url(repo: str) -> str:
|
||||||
return repo.replace(".git", "").replace("https://", "").replace("git@", "")
|
return repo.replace(".git", "").replace("https://", "").replace("git@", "")
|
||||||
|
|
||||||
if not klipper_status.repo == "-":
|
if klipper_status.repo:
|
||||||
url = trim_repo_url(klipper_status.repo_url)
|
url = trim_repo_url(klipper_status.repo_url)
|
||||||
self.kl_repo_url = Color.apply(url, Color.CYAN)
|
self.kl_repo_url = Color.apply(url, Color.CYAN)
|
||||||
self.kl_branch = Color.apply(klipper_status.branch, Color.CYAN)
|
self.kl_branch = Color.apply(klipper_status.branch, Color.CYAN)
|
||||||
if not moonraker_status.repo == "-":
|
if moonraker_status.repo:
|
||||||
url = trim_repo_url(moonraker_status.repo_url)
|
url = trim_repo_url(moonraker_status.repo_url)
|
||||||
self.mr_repo_url = Color.apply(url, Color.CYAN)
|
self.mr_repo_url = Color.apply(url, Color.CYAN)
|
||||||
self.mr_branch = Color.apply(moonraker_status.branch, Color.CYAN)
|
self.mr_branch = Color.apply(moonraker_status.branch, Color.CYAN)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -251,20 +251,23 @@ class UpdateMenu(BaseMenu):
|
|||||||
self._set_status_data("klipperscreen", get_klipperscreen_status)
|
self._set_status_data("klipperscreen", get_klipperscreen_status)
|
||||||
self._set_status_data("crowsnest", get_crowsnest_status)
|
self._set_status_data("crowsnest", get_crowsnest_status)
|
||||||
|
|
||||||
|
self._fetch_system_package_update_status()
|
||||||
|
|
||||||
|
def _fetch_system_package_update_status(self) -> None:
|
||||||
update_system_package_lists(silent=True)
|
update_system_package_lists(silent=True)
|
||||||
self.packages = get_upgradable_packages()
|
self.packages = get_upgradable_packages()
|
||||||
self.package_count = len(self.packages)
|
self.package_count = len(self.packages)
|
||||||
|
|
||||||
def _format_local_status(self, local_version, remote_version) -> str:
|
def _format_local_status(self, local_version, remote_version) -> str:
|
||||||
color = Color.RED
|
color = Color.RED
|
||||||
if not local_version:
|
if local_version is None:
|
||||||
color = Color.RED
|
color = Color.RED
|
||||||
elif local_version == remote_version:
|
elif local_version == remote_version:
|
||||||
color = Color.GREEN
|
color = Color.GREEN
|
||||||
elif local_version != remote_version:
|
elif local_version != remote_version:
|
||||||
color = Color.YELLOW
|
color = Color.YELLOW
|
||||||
|
|
||||||
return Color.apply(local_version or "-", color)
|
return str(Color.apply(local_version or '-', color))
|
||||||
|
|
||||||
def _set_status_data(self, name: str, status_fn: Callable, *args) -> None:
|
def _set_status_data(self, name: str, status_fn: Callable, *args) -> None:
|
||||||
comp_status: ComponentStatus = status_fn(*args)
|
comp_status: ComponentStatus = status_fn(*args)
|
||||||
@@ -290,7 +293,13 @@ class UpdateMenu(BaseMenu):
|
|||||||
return self.status_data[name]["installed"]
|
return self.status_data[name]["installed"]
|
||||||
|
|
||||||
def _is_update_available(self, name: str) -> bool:
|
def _is_update_available(self, name: str) -> bool:
|
||||||
return self.status_data[name]["local"] != self.status_data[name]["remote"]
|
local = self.status_data[name]["local"]
|
||||||
|
remote = self.status_data[name]["remote"]
|
||||||
|
|
||||||
|
if local is None or remote is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return local != remote
|
||||||
|
|
||||||
def _run_update_routine(self, name: str, update_fn: Callable, *args) -> None:
|
def _run_update_routine(self, name: str, update_fn: Callable, *args) -> None:
|
||||||
display_name = self.status_data[name]["display_name"]
|
display_name = self.status_data[name]["display_name"]
|
||||||
@@ -306,6 +315,27 @@ class UpdateMenu(BaseMenu):
|
|||||||
|
|
||||||
update_fn(*args)
|
update_fn(*args)
|
||||||
|
|
||||||
|
self._refresh_component_status(name)
|
||||||
|
|
||||||
|
def _refresh_component_status(self, name: str) -> None:
|
||||||
|
"""Refresh the status data for a component after an update."""
|
||||||
|
if name == "klipper":
|
||||||
|
self._set_status_data("klipper", get_klipper_status)
|
||||||
|
elif name == "moonraker":
|
||||||
|
self._set_status_data("moonraker", get_moonraker_status)
|
||||||
|
elif name == "mainsail":
|
||||||
|
self._set_status_data("mainsail", get_client_status, self.mainsail_data, True)
|
||||||
|
elif name == "mainsail_config":
|
||||||
|
self._set_status_data("mainsail_config", get_client_config_status, self.mainsail_data)
|
||||||
|
elif name == "fluidd":
|
||||||
|
self._set_status_data("fluidd", get_client_status, self.fluidd_data, True)
|
||||||
|
elif name == "fluidd_config":
|
||||||
|
self._set_status_data("fluidd_config", get_client_config_status, self.fluidd_data)
|
||||||
|
elif name == "klipperscreen":
|
||||||
|
self._set_status_data("klipperscreen", get_klipperscreen_status)
|
||||||
|
elif name == "crowsnest":
|
||||||
|
self._set_status_data("crowsnest", get_crowsnest_status)
|
||||||
|
|
||||||
def _run_system_updates(self) -> None:
|
def _run_system_updates(self) -> None:
|
||||||
if not self.packages:
|
if not self.packages:
|
||||||
Logger.print_info("No system upgrades available!")
|
Logger.print_info("No system upgrades available!")
|
||||||
@@ -313,15 +343,20 @@ class UpdateMenu(BaseMenu):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pkgs: str = ", ".join(self.packages)
|
pkgs: str = ", ".join(self.packages)
|
||||||
|
|
||||||
Logger.print_dialog(
|
Logger.print_dialog(
|
||||||
DialogType.CUSTOM,
|
DialogType.CUSTOM,
|
||||||
["The following packages will be upgraded:", "\n\n", pkgs],
|
["The following packages will be upgraded:", "\n\n", pkgs],
|
||||||
custom_title="UPGRADABLE SYSTEM UPDATES",
|
custom_title="UPGRADABLE SYSTEM UPDATES",
|
||||||
)
|
)
|
||||||
if not get_confirm("Continue?"):
|
|
||||||
|
if not get_confirm("Upgrade packages?"):
|
||||||
return
|
return
|
||||||
|
|
||||||
Logger.print_status("Upgrading system packages ...")
|
Logger.print_status("Upgrading system packages ...")
|
||||||
|
|
||||||
upgrade_system_packages(self.packages)
|
upgrade_system_packages(self.packages)
|
||||||
|
self._fetch_system_package_update_status()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.print_error(f"Error upgrading system packages:\n{e}")
|
Logger.print_error(f"Error upgrading system packages:\n{e}")
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -22,6 +22,7 @@ from utils.instance_utils import get_instances
|
|||||||
class BackupService:
|
class BackupService:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._backup_root = Path.home().joinpath("kiauh_backups")
|
self._backup_root = Path.home().joinpath("kiauh_backups")
|
||||||
|
self._timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def backup_root(self) -> Path:
|
def backup_root(self) -> Path:
|
||||||
@@ -29,7 +30,7 @@ class BackupService:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def timestamp(self) -> str:
|
def timestamp(self) -> str:
|
||||||
return datetime.now().strftime("%Y%m%d-%H%M%S")
|
return self._timestamp
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
# GENERIC BACKUP METHODS
|
# GENERIC BACKUP METHODS
|
||||||
@@ -68,10 +69,15 @@ class BackupService:
|
|||||||
backup_dir = self._backup_root.joinpath(target_path)
|
backup_dir = self._backup_root.joinpath(target_path)
|
||||||
|
|
||||||
backup_dir.mkdir(parents=True, exist_ok=True)
|
backup_dir.mkdir(parents=True, exist_ok=True)
|
||||||
shutil.copy2(source_path, backup_dir.joinpath(filename))
|
target_path = backup_dir.joinpath(filename)
|
||||||
|
if target_path.exists():
|
||||||
|
Logger.print_info(f"File '{target_path}' already exists. Skipping ...")
|
||||||
|
return True
|
||||||
|
|
||||||
|
shutil.copy2(source_path, target_path)
|
||||||
|
|
||||||
Logger.print_ok(
|
Logger.print_ok(
|
||||||
f"Successfully backed up '{source_path}' to '{backup_dir}'"
|
f"Successfully backed up '{source_path}' to '{target_path}'"
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -111,7 +117,18 @@ class BackupService:
|
|||||||
|
|
||||||
if backup_path.exists():
|
if backup_path.exists():
|
||||||
Logger.print_info(f"Reusing existing backup directory '{backup_path}'")
|
Logger.print_info(f"Reusing existing backup directory '{backup_path}'")
|
||||||
|
for item in source_path.rglob("*"):
|
||||||
|
relative_path = item.relative_to(source_path)
|
||||||
|
target_item = backup_path.joinpath(relative_path)
|
||||||
|
if item.is_file():
|
||||||
|
if not target_item.exists():
|
||||||
|
target_item.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
shutil.copy2(item, target_item)
|
||||||
|
else:
|
||||||
|
Logger.print_info(f"File '{target_item}' already exists. Skipping...")
|
||||||
|
elif item.is_dir():
|
||||||
|
target_item.mkdir(parents=True, exist_ok=True)
|
||||||
|
else:
|
||||||
shutil.copytree(
|
shutil.copytree(
|
||||||
source_path,
|
source_path,
|
||||||
backup_path,
|
backup_path,
|
||||||
@@ -134,27 +151,29 @@ class BackupService:
|
|||||||
################################################
|
################################################
|
||||||
|
|
||||||
def backup_printer_cfg(self):
|
def backup_printer_cfg(self):
|
||||||
|
"""Backup printer.cfg files of all Klipper instances.
|
||||||
|
Files are backed up to:
|
||||||
|
{backup_root}/{instance_data_dir_name}/printer_{timestamp}.cfg
|
||||||
|
"""
|
||||||
klipper_instances: List[Klipper] = get_instances(Klipper)
|
klipper_instances: List[Klipper] = get_instances(Klipper)
|
||||||
for instance in klipper_instances:
|
for instance in klipper_instances:
|
||||||
target_path: Path = self._backup_root.joinpath(
|
target_path: Path = self._backup_root.joinpath(instance.data_dir.name)
|
||||||
instance.data_dir.name, f"config_{self.timestamp}"
|
|
||||||
)
|
|
||||||
self.backup_file(
|
self.backup_file(
|
||||||
source_path=instance.cfg_file,
|
source_path=instance.cfg_file,
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
target_name=instance.cfg_file.name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def backup_moonraker_conf(self):
|
def backup_moonraker_conf(self):
|
||||||
|
"""Backup moonraker.conf files of all Moonraker instances.
|
||||||
|
Files are backed up to:
|
||||||
|
{backup_root}/{instance_data_dir_name}/moonraker_{timestamp}.conf
|
||||||
|
"""
|
||||||
moonraker_instances: List[Moonraker] = get_instances(Moonraker)
|
moonraker_instances: List[Moonraker] = get_instances(Moonraker)
|
||||||
for instance in moonraker_instances:
|
for instance in moonraker_instances:
|
||||||
target_path: Path = self._backup_root.joinpath(
|
target_path: Path = self._backup_root.joinpath(instance.data_dir.name)
|
||||||
instance.data_dir.name, f"config_{self.timestamp}"
|
|
||||||
)
|
|
||||||
self.backup_file(
|
self.backup_file(
|
||||||
source_path=instance.cfg_file,
|
source_path=instance.cfg_file,
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
target_name=instance.cfg_file.name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def backup_printer_config_dir(self) -> None:
|
def backup_printer_config_dir(self) -> None:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
# Copyright (C) 2020 - 2025 Dominik Willner <th33xitus@gmail.com> #
|
# Copyright (C) 2020 - 2026 Dominik Willner <th33xitus@gmail.com> #
|
||||||
# #
|
# #
|
||||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
# https://github.com/dw-0/kiauh #
|
# https://github.com/dw-0/kiauh #
|
||||||
@@ -16,7 +16,7 @@ from components.klipper import KLIPPER_REPO_URL
|
|||||||
from components.moonraker import MOONRAKER_REPO_URL
|
from components.moonraker import MOONRAKER_REPO_URL
|
||||||
from core.logger import DialogType, Logger
|
from core.logger import DialogType, Logger
|
||||||
from core.services.backup_service import BackupService
|
from core.services.backup_service import BackupService
|
||||||
from core.submodules.simple_config_parser.src.simple_config_parser.simple_config_parser import (
|
from core.simple_config_parser.simple_config_parser import (
|
||||||
SimpleConfigParser,
|
SimpleConfigParser,
|
||||||
)
|
)
|
||||||
from utils.input_utils import get_confirm
|
from utils.input_utils import get_confirm
|
||||||
|
|||||||
+2
-2
@@ -10,8 +10,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.simple_config_parser.simple_config_parser import SimpleConfigParser
|
from core.simple_config_parser.simple_config_parser import SimpleConfigParser
|
||||||
from tests.utils import load_testdata_from_file
|
from core.simple_config_parser.tests.utils import load_testdata_from_file
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
||||||
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
||||||
+2
-2
@@ -10,8 +10,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.simple_config_parser.simple_config_parser import SimpleConfigParser
|
from core.simple_config_parser.simple_config_parser import SimpleConfigParser
|
||||||
from tests.utils import load_testdata_from_file
|
from core.simple_config_parser.tests.utils import load_testdata_from_file
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
||||||
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
||||||
+2
-2
@@ -10,8 +10,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.simple_config_parser.simple_config_parser import SimpleConfigParser
|
from core.simple_config_parser.simple_config_parser import SimpleConfigParser
|
||||||
from tests.utils import load_testdata_from_file
|
from core.simple_config_parser.tests.utils import load_testdata_from_file
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
||||||
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
||||||
+2
-2
@@ -10,8 +10,8 @@ from pathlib import Path
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.simple_config_parser.simple_config_parser import SimpleConfigParser
|
from core.simple_config_parser.simple_config_parser import SimpleConfigParser
|
||||||
from tests.utils import load_testdata_from_file
|
from core.simple_config_parser.tests.utils import load_testdata_from_file
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
BASE_DIR = Path(__file__).parent.joinpath("test_data")
|
||||||
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
MATCHING_TEST_DATA_PATH = BASE_DIR.joinpath("matching_data.txt")
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user