mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-15 03:24:29 +05:00
Compare commits
4 Commits
v6.0.0-alp
...
v6.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf4e915430 | ||
|
|
c901cd1fdf | ||
|
|
da3c37a872 | ||
|
|
8f436646cd |
@@ -11,5 +11,5 @@ end_of_line = lf
|
||||
[*.py]
|
||||
max_line_length = 88
|
||||
|
||||
[*.sh]
|
||||
[*.{sh,yml,yaml}]
|
||||
indent_size = 2
|
||||
28
.github/workflows/fast-forward.yml
vendored
Normal file
28
.github/workflows/fast-forward.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
27
.github/workflows/pull-request.yml
vendored
Normal file
27
.github/workflows/pull-request.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
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
|
||||
@@ -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
|
||||
from utils.sys_utils import (
|
||||
cmd_sysctl_service,
|
||||
install_python_packages,
|
||||
parse_packages_from_file,
|
||||
)
|
||||
|
||||
|
||||
def get_klipper_status() -> ComponentStatus:
|
||||
@@ -211,3 +215,42 @@ def install_klipper_packages() -> None:
|
||||
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})
|
||||
|
||||
@@ -13,6 +13,7 @@ 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,
|
||||
@@ -50,9 +51,10 @@ class AdvancedMenu(BaseMenu):
|
||||
"2": Option(method=self.flash),
|
||||
"3": Option(method=self.build_flash),
|
||||
"4": Option(method=self.get_id),
|
||||
"5": Option(method=self.klipper_rollback),
|
||||
"6": Option(method=self.moonraker_rollback),
|
||||
"7": Option(method=self.change_hostname),
|
||||
"5": Option(method=self.input_shaper),
|
||||
"6": Option(method=self.klipper_rollback),
|
||||
"7": Option(method=self.moonraker_rollback),
|
||||
"8": Option(method=self.change_hostname),
|
||||
}
|
||||
|
||||
def print_menu(self) -> None:
|
||||
@@ -60,11 +62,13 @@ class AdvancedMenu(BaseMenu):
|
||||
"""
|
||||
╟───────────────────────────┬───────────────────────────╢
|
||||
║ Klipper Firmware: │ Repository Rollback: ║
|
||||
║ 1) [Build] │ 5) [Klipper] ║
|
||||
║ 2) [Flash] │ 6) [Moonraker] ║
|
||||
║ 1) [Build] │ 6) [Klipper] ║
|
||||
║ 2) [Flash] │ 7) [Moonraker] ║
|
||||
║ 3) [Build + Flash] │ ║
|
||||
║ 4) [Get MCU ID] │ System: ║
|
||||
║ │ 7) [Change hostname] ║
|
||||
║ │ 8) [Change hostname] ║
|
||||
║ Extra Dependencies: │ ║
|
||||
║ 5) [Input Shaper] │ ║
|
||||
╟───────────────────────────┴───────────────────────────╢
|
||||
"""
|
||||
)[1:]
|
||||
@@ -97,3 +101,6 @@ class AdvancedMenu(BaseMenu):
|
||||
|
||||
def change_hostname(self, **kwargs) -> None:
|
||||
change_system_hostname()
|
||||
|
||||
def input_shaper(self, **kwargs) -> None:
|
||||
install_input_shaper_deps()
|
||||
|
||||
@@ -26,9 +26,10 @@ 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, the default branch will be checked out.
|
||||
:param branch: The branch to check out. If None, master or main, no checkout will be performed.
|
||||
: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
|
||||
@@ -43,8 +44,11 @@ def git_clone_wrapper(
|
||||
return
|
||||
shutil.rmtree(target_dir)
|
||||
|
||||
git_cmd_clone(repo, target_dir)
|
||||
git_cmd_checkout(branch, target_dir)
|
||||
git_cmd_clone(repo, target_dir, blobless=True)
|
||||
|
||||
if branch not in ("master", "main"):
|
||||
git_cmd_checkout(branch, target_dir)
|
||||
|
||||
except CalledProcessError:
|
||||
log = "An unexpected error occured during cloning of the repository."
|
||||
Logger.print_error(log)
|
||||
@@ -255,11 +259,23 @@ def get_remote_commit(repo: Path) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def git_cmd_clone(repo: str, target_dir: Path) -> None:
|
||||
try:
|
||||
command = ["git", "clone", repo, target_dir.as_posix()]
|
||||
run(command, check=True)
|
||||
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.
|
||||
"""
|
||||
try:
|
||||
command = ["git", "clone"]
|
||||
|
||||
if blobless:
|
||||
command.append("--filter=blob:none")
|
||||
|
||||
command += [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"
|
||||
|
||||
@@ -197,6 +197,38 @@ 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 |
|
||||
|
||||
Reference in New Issue
Block a user