mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-26 17:23:35 +05:00
Compare commits
9 Commits
f225ed028d
...
v6.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
243ea6582a | ||
|
|
a63cf8c9d9 | ||
|
|
425d86a12f | ||
|
|
1b5691f2f5 | ||
|
|
dc026a7a2b | ||
|
|
a8a73249a5 | ||
|
|
ec3f93eeda | ||
|
|
4cf523a758 | ||
|
|
1d06bf76f3 |
@@ -37,7 +37,6 @@ from components.webui_client.client_utils import (
|
||||
)
|
||||
from core.instance_manager.instance_manager import InstanceManager
|
||||
from core.logger import DialogType, Logger
|
||||
from core.services.message_service import Message
|
||||
from core.settings.kiauh_settings import KiauhSettings
|
||||
from core.types.color import Color
|
||||
from utils.common import backup_printer_config_dir, check_install_dependencies
|
||||
@@ -56,21 +55,14 @@ def install_client(
|
||||
client: BaseWebClient,
|
||||
settings: KiauhSettings,
|
||||
reinstall: bool = False,
|
||||
) -> Message:
|
||||
completion_msg = Message(
|
||||
title=f"{client.display_name} Installation Process completed",
|
||||
color=Color.GREEN,
|
||||
)
|
||||
) -> None:
|
||||
mr_instances: List[Moonraker] = get_instances(Moonraker)
|
||||
|
||||
enable_remotemode = False
|
||||
if not mr_instances:
|
||||
print_moonraker_not_found_dialog(client.display_name)
|
||||
if not get_confirm(f"Continue {client.display_name} installation?"):
|
||||
completion_msg.color = Color.YELLOW
|
||||
completion_msg.title = f"{client.display_name} Installation Process aborted"
|
||||
completion_msg.text.append("Installation was aborted by the user!")
|
||||
return completion_msg
|
||||
return
|
||||
|
||||
# if moonraker is not installed or multiple instances
|
||||
# are installed we enable mainsails remote mode
|
||||
@@ -98,9 +90,9 @@ def install_client(
|
||||
default_port if reinstall else get_client_port_selection(client, settings)
|
||||
)
|
||||
|
||||
try:
|
||||
check_install_dependencies({"nginx"})
|
||||
check_install_dependencies({"nginx"})
|
||||
|
||||
try:
|
||||
download_client(client)
|
||||
if enable_remotemode and client.client == WebClientType.MAINSAIL:
|
||||
enable_mainsail_remotemode()
|
||||
@@ -138,17 +130,23 @@ def install_client(
|
||||
|
||||
except Exception as e:
|
||||
Logger.print_error(e)
|
||||
completion_msg.color = Color.RED
|
||||
completion_msg.title = f"{client.display_name} Installation Process failed!"
|
||||
completion_msg.text.append(
|
||||
f"An unexpected error occured. Please see the output above. {client.display_name} installation failed!")
|
||||
return completion_msg
|
||||
Logger.print_dialog(
|
||||
DialogType.ERROR,
|
||||
center_content=True,
|
||||
content=[f"{client.display_name} installation failed!"],
|
||||
)
|
||||
return
|
||||
|
||||
# noinspection HttpUrlsUsage
|
||||
completion_msg.text.append(
|
||||
f"Open {client.display_name} now on: http://{get_ipv4_addr()}:{port}")
|
||||
|
||||
return completion_msg
|
||||
Logger.print_dialog(
|
||||
DialogType.CUSTOM,
|
||||
custom_title=f"{client.display_name} installation complete!",
|
||||
custom_color=Color.GREEN,
|
||||
center_content=True,
|
||||
content=[
|
||||
f"Open {client.display_name} now on: http://{get_ipv4_addr()}:{port}",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def download_client(client: BaseWebClient) -> None:
|
||||
|
||||
@@ -65,8 +65,7 @@ class ClientInstallMenu(BaseMenu):
|
||||
print(menu, end="")
|
||||
|
||||
def reinstall_client(self, **kwargs) -> None:
|
||||
completion_msg = install_client(self.client, settings=self.settings, reinstall=True)
|
||||
self.message_service.set_message(completion_msg)
|
||||
install_client(self.client, settings=self.settings, reinstall=True)
|
||||
|
||||
def change_listen_port(self, **kwargs) -> None:
|
||||
curr_port = self._get_current_port()
|
||||
|
||||
@@ -79,14 +79,14 @@ class BackupManager:
|
||||
|
||||
if source is None or not Path(source).exists():
|
||||
Logger.print_info("Source directory does not exist! Skipping ...")
|
||||
return None
|
||||
return
|
||||
|
||||
target = self.backup_root_dir if target is None else target
|
||||
try:
|
||||
date = get_current_date().get("date")
|
||||
time = get_current_date().get("time")
|
||||
backup_target = target.joinpath(f"{name.lower()}-{date}-{time}")
|
||||
shutil.copytree(source, backup_target, ignore=self.ignore_folders_func, ignore_dangling_symlinks=True)
|
||||
shutil.copytree(source, backup_target, ignore=self.ignore_folders_func)
|
||||
Logger.print_ok("Backup successful!")
|
||||
|
||||
return backup_target
|
||||
|
||||
@@ -81,13 +81,21 @@ class InstallMenu(BaseMenu):
|
||||
moonraker_setup.install_moonraker()
|
||||
|
||||
def install_mainsail(self, **kwargs) -> None:
|
||||
self._install_client(MainsailData())
|
||||
client: MainsailData = MainsailData()
|
||||
if client.client_dir.exists():
|
||||
ClientInstallMenu(client, self.__class__).run()
|
||||
else:
|
||||
install_client(client, settings=KiauhSettings())
|
||||
|
||||
def install_mainsail_config(self, **kwargs) -> None:
|
||||
install_client_config(MainsailData())
|
||||
|
||||
def install_fluidd(self, **kwargs) -> None:
|
||||
self._install_client(FluiddData())
|
||||
client: FluiddData = FluiddData()
|
||||
if client.client_dir.exists():
|
||||
ClientInstallMenu(client, self.__class__).run()
|
||||
else:
|
||||
install_client(client, settings=KiauhSettings())
|
||||
|
||||
def install_fluidd_config(self, **kwargs) -> None:
|
||||
install_client_config(FluiddData())
|
||||
@@ -97,10 +105,3 @@ class InstallMenu(BaseMenu):
|
||||
|
||||
def install_crowsnest(self, **kwargs) -> None:
|
||||
install_crowsnest()
|
||||
|
||||
def _install_client(self, client: MainsailData | FluiddData) -> None:
|
||||
if client.client_dir.exists():
|
||||
ClientInstallMenu(client, self.__class__).run()
|
||||
else:
|
||||
completion_msg = install_client(client, settings=KiauhSettings())
|
||||
self.message_service.set_message(completion_msg)
|
||||
|
||||
@@ -118,7 +118,7 @@ class MoonrakerTelegramBot:
|
||||
)
|
||||
env_file_content = env_file_content.replace(
|
||||
"%CFG%",
|
||||
self.cfg_file.as_posix()
|
||||
f"{self.base.cfg_dir}/printer.cfg",
|
||||
)
|
||||
env_file_content = env_file_content.replace(
|
||||
"%LOG%",
|
||||
|
||||
@@ -43,8 +43,7 @@ def get_kiauh_version() -> str:
|
||||
Helper method to get the current KIAUH version by reading the latest tag
|
||||
:return: string of the latest tag
|
||||
"""
|
||||
lastest_tag: str = get_local_tags(Path(__file__).parent.parent)[-1]
|
||||
return lastest_tag
|
||||
return get_local_tags(Path(__file__).parent.parent)[-1]
|
||||
|
||||
|
||||
def convert_camelcase_to_kebabcase(name: str) -> str:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
import urllib.request
|
||||
from http.client import HTTPResponse
|
||||
@@ -119,7 +118,7 @@ def get_local_tags(repo_path: Path, _filter: str | None = None) -> List[str]:
|
||||
:return: List of tags
|
||||
"""
|
||||
try:
|
||||
cmd: List[str] = ["git", "tag", "-l"]
|
||||
cmd = ["git", "tag", "-l"]
|
||||
|
||||
if _filter is not None:
|
||||
cmd.append(f"'${_filter}'")
|
||||
@@ -130,10 +129,8 @@ def get_local_tags(repo_path: Path, _filter: str | None = None) -> List[str]:
|
||||
cwd=repo_path.as_posix(),
|
||||
).decode(encoding="utf-8")
|
||||
|
||||
tags: List[str] = result.split("\n")[:-1]
|
||||
|
||||
return sorted(tags, key=lambda x: [int(i) if i.isdigit() else i for i in
|
||||
re.split(r'(\d+)', x)])
|
||||
tags = result.split("\n")
|
||||
return tags[:-1]
|
||||
|
||||
except CalledProcessError:
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user