mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 16:23:36 +05:00
Compare commits
3 Commits
85b4b68f16
...
c28d5c28b9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c28d5c28b9 | ||
|
|
cda6d31a7c | ||
|
|
9a657daffd |
@@ -17,6 +17,11 @@ from kiauh.modules.klipper.klipper_setup import update_klipper
|
||||
from kiauh.modules.klipper.klipper_utils import (
|
||||
get_klipper_status,
|
||||
)
|
||||
from kiauh.modules.mainsail.mainsail_setup import update_mainsail
|
||||
from kiauh.modules.mainsail.mainsail_utils import (
|
||||
get_mainsail_local_version,
|
||||
get_mainsail_remote_version,
|
||||
)
|
||||
from kiauh.modules.moonraker.moonraker_setup import update_moonraker
|
||||
from kiauh.modules.moonraker.moonraker_utils import get_moonraker_status
|
||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_WHITE
|
||||
@@ -48,6 +53,8 @@ class UpdateMenu(BaseMenu):
|
||||
self.kl_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.mr_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.mr_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.ms_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.ms_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
|
||||
def print_menu(self):
|
||||
self.fetch_update_status()
|
||||
@@ -67,7 +74,7 @@ class UpdateMenu(BaseMenu):
|
||||
| 2) Moonraker | {self.mr_local:<22} | {self.mr_remote:<22} |
|
||||
| | | |
|
||||
| Klipper Webinterface: |---------------|---------------|
|
||||
| 3) Mainsail | | |
|
||||
| 3) Mainsail | {self.ms_local:<22} | {self.ms_remote:<22} |
|
||||
| 4) Fluidd | | |
|
||||
| | | |
|
||||
| Touchscreen GUI: |---------------|---------------|
|
||||
@@ -96,7 +103,7 @@ class UpdateMenu(BaseMenu):
|
||||
update_moonraker()
|
||||
|
||||
def update_mainsail(self):
|
||||
print("update_mainsail")
|
||||
update_mainsail()
|
||||
|
||||
def update_fluidd(self):
|
||||
print("update_fluidd")
|
||||
@@ -144,3 +151,11 @@ class UpdateMenu(BaseMenu):
|
||||
else:
|
||||
self.mr_local = f"{COLOR_YELLOW}{self.mr_local}{RESET_FORMAT}"
|
||||
self.mr_remote = f"{COLOR_GREEN}{self.mr_remote}{RESET_FORMAT}"
|
||||
# mainsail
|
||||
self.ms_local = get_mainsail_local_version()
|
||||
self.ms_remote = get_mainsail_remote_version()
|
||||
if self.ms_local == self.ms_remote:
|
||||
self.ms_local = f"{COLOR_GREEN}{self.ms_local}{RESET_FORMAT}"
|
||||
else:
|
||||
self.ms_local = f"{COLOR_YELLOW}{self.ms_local}{RESET_FORMAT}"
|
||||
self.ms_remote = f"{COLOR_GREEN}{self.ms_remote}{RESET_FORMAT}"
|
||||
|
||||
@@ -69,6 +69,9 @@ class RepoManager:
|
||||
:param repo: repository to extract the values from
|
||||
:return: String in form of "<orga>/<name>"
|
||||
"""
|
||||
if not repo.exists() and not repo.joinpath(".git").exists():
|
||||
return "-"
|
||||
|
||||
try:
|
||||
cmd = ["git", "-C", repo, "config", "--get", "remote.origin.url"]
|
||||
result = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
|
||||
@@ -78,7 +81,7 @@ class RepoManager:
|
||||
|
||||
@staticmethod
|
||||
def get_local_commit(repo: Path) -> str:
|
||||
if not repo.exists() and repo.joinpath(".git").exists():
|
||||
if not repo.exists() and not repo.joinpath(".git").exists():
|
||||
return "-"
|
||||
|
||||
try:
|
||||
@@ -89,7 +92,7 @@ class RepoManager:
|
||||
|
||||
@staticmethod
|
||||
def get_remote_commit(repo: Path) -> str:
|
||||
if not repo.exists() and repo.joinpath(".git").exists():
|
||||
if not repo.exists() and not repo.joinpath(".git").exists():
|
||||
return "-"
|
||||
|
||||
try:
|
||||
|
||||
@@ -114,10 +114,9 @@ def setup_klipper_prerequesites() -> None:
|
||||
repo_manager.clone_repo()
|
||||
|
||||
# install klipper dependencies and create python virtualenv
|
||||
install_klipper_packages(Path(KLIPPER_DIR))
|
||||
create_python_venv(Path(KLIPPER_ENV_DIR))
|
||||
klipper_py_req = Path(KLIPPER_REQUIREMENTS_TXT)
|
||||
install_python_requirements(Path(KLIPPER_ENV_DIR), klipper_py_req)
|
||||
install_klipper_packages(KLIPPER_DIR)
|
||||
create_python_venv(KLIPPER_ENV_DIR)
|
||||
install_python_requirements(KLIPPER_ENV_DIR, KLIPPER_REQUIREMENTS_TXT)
|
||||
|
||||
|
||||
def install_klipper_packages(klipper_dir: Path) -> None:
|
||||
|
||||
@@ -162,6 +162,13 @@ def download_mainsail() -> None:
|
||||
raise
|
||||
|
||||
|
||||
def update_mainsail() -> None:
|
||||
Logger.print_status("Updating Mainsail ...")
|
||||
backup_config_json(is_temp=True)
|
||||
download_mainsail()
|
||||
restore_config_json()
|
||||
|
||||
|
||||
def download_mainsail_cfg() -> None:
|
||||
try:
|
||||
Logger.print_status("Downloading mainsail-config ...")
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
import json
|
||||
import shutil
|
||||
import requests
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
@@ -80,3 +81,19 @@ def symlink_webui_nginx_log(klipper_instances: List[Klipper]) -> None:
|
||||
desti_error = instance.log_dir.joinpath("mainsail-error.log")
|
||||
if not desti_error.exists():
|
||||
desti_error.symlink_to(error_log)
|
||||
|
||||
|
||||
def get_mainsail_local_version() -> str:
|
||||
relinfo_file = MAINSAIL_DIR.joinpath("release_info.json")
|
||||
if not relinfo_file.is_file():
|
||||
return "-"
|
||||
|
||||
with open(relinfo_file, "r") as f:
|
||||
return json.load(f)["version"]
|
||||
|
||||
|
||||
def get_mainsail_remote_version() -> str:
|
||||
url = "https://api.github.com/repos/mainsail-crew/mainsail/tags"
|
||||
response = requests.get(url)
|
||||
data = json.loads(response.text)
|
||||
return data[0]["name"]
|
||||
|
||||
@@ -17,6 +17,7 @@ import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import venv
|
||||
from pathlib import Path
|
||||
from typing import List, Literal
|
||||
|
||||
@@ -68,14 +69,10 @@ def create_python_venv(target: Path) -> None:
|
||||
Logger.print_status("Set up Python virtual environment ...")
|
||||
if not target.exists():
|
||||
try:
|
||||
command = ["python3", "-m", "venv", f"{target}"]
|
||||
result = subprocess.run(command, stderr=subprocess.PIPE, text=True)
|
||||
if result.returncode != 0 or result.stderr:
|
||||
Logger.print_error(f"{result.stderr}", prefix=False)
|
||||
Logger.print_error("Setup of virtualenv failed!")
|
||||
return
|
||||
|
||||
venv.create(target, with_pip=True)
|
||||
Logger.print_ok("Setup of virtualenv successfull!")
|
||||
except OSError as e:
|
||||
Logger.print_error(f"Error setting up virtualenv:\n{e}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
Logger.print_error(f"Error setting up virtualenv:\n{e.output.decode()}")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user