Compare commits

..

4 Commits

Author SHA1 Message Date
dw-0
93ab78a88f style: ruff format
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2025-03-08 16:45:20 +01:00
dw-0
3963d1174d refactor(klipper): move setup functions into KlipperSetupService
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2025-03-08 16:19:47 +01:00
dw-0
a272bf7e41 feat(moonraker): display moonraker ip address after install
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
2025-03-08 11:40:22 +01:00
CODeRUS
41d3d749b0 fix: Add pkg-config to klipper packages (#655)
Signed-off-by: Andrey Kozhevnikov <coderusinbox@gmail.com>
2025-03-06 18:33:55 +01:00
8 changed files with 19 additions and 174 deletions

View File

@@ -11,5 +11,5 @@ end_of_line = lf
[*.py]
max_line_length = 88
[*.{sh,yml,yaml}]
indent_size = 2
[*.sh]
indent_size = 2

View File

@@ -1,28 +0,0 @@
name: fast-forward
on:
issue_comment:
types: [ created, edited ]
jobs:
fast-forward:
# Only run if the comment contains the /fast-forward command.
if: |
contains(github.event.comment.body, '/fast-forward') &&
github.event.issue.pull_request &&
github.base_ref == 'develop'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- name: Fast forwarding
uses: sequoia-pgp/fast-forward@v1
with:
merge: true
# To reduce the workflow's verbosity, use 'on-error'
# to only post a comment when an error occurs, or 'never' to
# never post a comment. (In all cases the information is
# still available in the step's summary.)
comment: on-error

View File

@@ -1,27 +0,0 @@
name: pull-request
on:
pull_request:
branches:
- develop
types: [ opened, reopened, synchronize ]
jobs:
check-fast-forward:
runs-on: ubuntu-latest
permissions:
contents: read
# We appear to need write permission for both pull-requests and
# issues in order to post a comment to a pull request.
pull-requests: write
issues: write
steps:
- name: Checking if fast forwarding is possible
uses: sequoia-pgp/fast-forward@v1
with:
merge: false
# To reduce the workflow's verbosity, use 'on-error'
# to only post a comment when an error occurs, or 'never' to
# never post a comment. (In all cases the information is
# still available in the step's summary.)
comment: on-error

View File

@@ -40,14 +40,9 @@ from core.submodules.simple_config_parser.src.simple_config_parser.simple_config
)
from core.types.component_status import ComponentStatus
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,
install_python_packages,
parse_packages_from_file,
)
from utils.sys_utils import cmd_sysctl_service, parse_packages_from_file
def get_klipper_status() -> ComponentStatus:
@@ -211,46 +206,7 @@ def install_klipper_packages() -> None:
packages.append("pkg-config")
# Add dbus requirement for DietPi distro
if check_file_exist(Path("/boot/dietpi/.version")):
if Path("/boot/dietpi/.version").exists():
packages.append("dbus")
check_install_dependencies({*packages})
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 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",
"Also, the following Python package will be installed:",
"● numpy",
],
custom_title="Install Input Shaper Dependencies",
)
if not get_confirm(
"Do you want to install the required packages?", default_choice=False
):
return
apt_deps = (
"python3-numpy",
"python3-matplotlib",
"libatlas-base-dev",
"libopenblas-dev",
)
check_install_dependencies({*apt_deps})
py_deps = ("numpy",)
install_python_packages(KLIPPER_ENV_DIR, {*py_deps})

View File

@@ -13,7 +13,6 @@ from typing import Type
from components.klipper import KLIPPER_DIR
from components.klipper.klipper import Klipper
from components.klipper.klipper_utils import install_input_shaper_deps
from components.klipper_firmware.menus.klipper_build_menu import (
KlipperBuildFirmwareMenu,
KlipperKConfigMenu,
@@ -51,10 +50,9 @@ class AdvancedMenu(BaseMenu):
"2": Option(method=self.flash),
"3": Option(method=self.build_flash),
"4": Option(method=self.get_id),
"5": Option(method=self.input_shaper),
"6": Option(method=self.klipper_rollback),
"7": Option(method=self.moonraker_rollback),
"8": Option(method=self.change_hostname),
"5": Option(method=self.klipper_rollback),
"6": Option(method=self.moonraker_rollback),
"7": Option(method=self.change_hostname),
}
def print_menu(self) -> None:
@@ -62,13 +60,11 @@ class AdvancedMenu(BaseMenu):
"""
╟───────────────────────────┬───────────────────────────╢
║ Klipper Firmware: │ Repository Rollback: ║
║ 1) [Build] │ 6) [Klipper] ║
║ 2) [Flash] │ 7) [Moonraker] ║
║ 1) [Build] │ 5) [Klipper] ║
║ 2) [Flash] │ 6) [Moonraker] ║
║ 3) [Build + Flash] │ ║
║ 4) [Get MCU ID] │ System: ║
║ │ 8) [Change hostname] ║
║ Extra Dependencies: │ ║
║ 5) [Input Shaper] │ ║
║ │ 7) [Change hostname] ║
╟───────────────────────────┴───────────────────────────╢
"""
)[1:]
@@ -101,6 +97,3 @@ class AdvancedMenu(BaseMenu):
def change_hostname(self, **kwargs) -> None:
change_system_hostname()
def input_shaper(self, **kwargs) -> None:
install_input_shaper_deps()

View File

@@ -10,7 +10,6 @@
# ======================================================================= #
from __future__ import annotations
import os
import re
import shutil
from pathlib import Path
@@ -30,15 +29,15 @@ def check_file_exist(file_path: Path, sudo=False) -> bool:
:return: True, if file exists, otherwise False
"""
if sudo:
command = ["sudo", "find", file_path.as_posix()]
try:
command = ["sudo", "find", file_path.as_posix()]
check_output(command, stderr=DEVNULL)
return True
except CalledProcessError:
return False
else:
if os.access(file_path, os.F_OK):
return file_path.exists()
if file_path.exists():
return True
else:
return False

View File

@@ -26,10 +26,9 @@ def git_clone_wrapper(
) -> None:
"""
Clones a repository from the given URL and checks out the specified branch if given.
The clone will be performed with the '--filter=blob:none' flag to perform a blobless clone.
:param repo: The URL of the repository to clone.
:param branch: The branch to check out. If None, master or main, no checkout will be performed.
:param branch: The branch to check out. If None, the default branch will be checked out.
:param target_dir: The directory where the repository will be cloned.
:param force: Force the cloning of the repository even if it already exists.
:return: None
@@ -44,11 +43,8 @@ def git_clone_wrapper(
return
shutil.rmtree(target_dir)
git_cmd_clone(repo, target_dir, blobless=True)
if branch not in ("master", "main"):
git_cmd_checkout(branch, target_dir)
git_cmd_clone(repo, target_dir)
git_cmd_checkout(branch, target_dir)
except CalledProcessError:
log = "An unexpected error occured during cloning of the repository."
Logger.print_error(log)
@@ -259,23 +255,11 @@ def get_remote_commit(repo: Path) -> str | None:
return None
def git_cmd_clone(repo: str, target_dir: Path, blobless: bool = False) -> None:
"""
Clones a repository with optional blobless clone.
:param repo: URL of the repository to clone.
:param target_dir: Path where the repository will be cloned.
:param blobless: If True, perform a blobless clone by adding the '--filter=blob:none' flag.
"""
def git_cmd_clone(repo: str, target_dir: Path) -> None:
try:
command = ["git", "clone"]
if blobless:
command.append("--filter=blob:none")
command += [repo, target_dir.as_posix()]
command = ["git", "clone", repo, target_dir.as_posix()]
run(command, check=True)
Logger.print_ok("Clone successful!")
except CalledProcessError as e:
error = e.stderr.decode() if e.stderr else "Unknown error"

View File

@@ -197,38 +197,6 @@ def install_python_requirements(target: Path, requirements: Path) -> None:
raise VenvCreationFailedException(log)
def install_python_packages(target: Path, packages: List[str]) -> None:
"""
Installs the python packages based on a provided packages list |
:param target: Path of the virtualenv
:param packages: str list of required packages
:return: None
"""
try:
# always update pip before installing requirements
update_python_pip(target)
Logger.print_status("Installing Python requirements ...")
command = [
target.joinpath("bin/pip").as_posix(),
"install",
]
for pkg in packages:
command.append(pkg)
result = run(command, stderr=PIPE, text=True)
if result.returncode != 0 or result.stderr:
Logger.print_error(f"{result.stderr}", False)
raise VenvCreationFailedException("Installing Python requirements failed!")
Logger.print_ok("Installing Python requirements successful!")
except Exception as e:
log = f"Error installing Python requirements: {e}"
Logger.print_error(log)
raise VenvCreationFailedException(log)
def update_system_package_lists(silent: bool, rls_info_change=False) -> None:
"""
Updates the systems package list |