mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-27 01:33:36 +05:00
Compare commits
5 Commits
df414ce37e
...
v6.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec3f93eeda | ||
|
|
afeb2bf02e | ||
|
|
4b17c68454 | ||
|
|
4cf523a758 | ||
|
|
1d06bf76f3 |
@@ -42,7 +42,7 @@ from core.menus.settings_menu import SettingsMenu
|
|||||||
from core.menus.update_menu import UpdateMenu
|
from core.menus.update_menu import UpdateMenu
|
||||||
from core.types import ComponentStatus, StatusMap, StatusText
|
from core.types import ComponentStatus, StatusMap, StatusText
|
||||||
from extensions.extensions_menu import ExtensionsMenu
|
from extensions.extensions_menu import ExtensionsMenu
|
||||||
from utils.common import get_kiauh_version
|
from utils.common import get_kiauh_version, trunc_string
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
@@ -100,8 +100,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 = status_data.owner
|
owner: str = trunc_string(status_data.owner, 23)
|
||||||
repo: str = status_data.repo
|
repo: str = trunc_string(status_data.repo, 23)
|
||||||
instance_count: int = status_data.instances
|
instance_count: int = status_data.instances
|
||||||
|
|
||||||
count_txt: str = ""
|
count_txt: str = ""
|
||||||
|
|||||||
@@ -73,14 +73,54 @@ class UpdateMenu(BaseMenu):
|
|||||||
self.mainsail_data = MainsailData()
|
self.mainsail_data = MainsailData()
|
||||||
self.fluidd_data = FluiddData()
|
self.fluidd_data = FluiddData()
|
||||||
self.status_data = {
|
self.status_data = {
|
||||||
"klipper": {"installed": False, "local": None, "remote": None},
|
"klipper": {
|
||||||
"moonraker": {"installed": False, "local": None, "remote": None},
|
"display_name": "Klipper",
|
||||||
"mainsail": {"installed": False, "local": None, "remote": None},
|
"installed": False,
|
||||||
"mainsail_config": {"installed": False, "local": None, "remote": None},
|
"local": None,
|
||||||
"fluidd": {"installed": False, "local": None, "remote": None},
|
"remote": None,
|
||||||
"fluidd_config": {"installed": False, "local": None, "remote": None},
|
},
|
||||||
"klipperscreen": {"installed": False, "local": None, "remote": None},
|
"moonraker": {
|
||||||
"crowsnest": {"installed": False, "local": None, "remote": None},
|
"display_name": "Moonraker",
|
||||||
|
"installed": False,
|
||||||
|
"local": None,
|
||||||
|
"remote": None,
|
||||||
|
},
|
||||||
|
"mainsail": {
|
||||||
|
"display_name": "Mainsail",
|
||||||
|
"installed": False,
|
||||||
|
"local": None,
|
||||||
|
"remote": None,
|
||||||
|
},
|
||||||
|
"mainsail_config": {
|
||||||
|
"display_name": "Mainsail-Config",
|
||||||
|
"installed": False,
|
||||||
|
"local": None,
|
||||||
|
"remote": None,
|
||||||
|
},
|
||||||
|
"fluidd": {
|
||||||
|
"display_name": "Fluidd",
|
||||||
|
"installed": False,
|
||||||
|
"local": None,
|
||||||
|
"remote": None,
|
||||||
|
},
|
||||||
|
"fluidd_config": {
|
||||||
|
"display_name": "Fluidd-Config",
|
||||||
|
"installed": False,
|
||||||
|
"local": None,
|
||||||
|
"remote": None,
|
||||||
|
},
|
||||||
|
"klipperscreen": {
|
||||||
|
"display_name": "KlipperScreen",
|
||||||
|
"installed": False,
|
||||||
|
"local": None,
|
||||||
|
"remote": None,
|
||||||
|
},
|
||||||
|
"crowsnest": {
|
||||||
|
"display_name": "Crowsnest",
|
||||||
|
"installed": False,
|
||||||
|
"local": None,
|
||||||
|
"remote": None,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_previous_menu(self, previous_menu: Type[BaseMenu] | None) -> None:
|
def set_previous_menu(self, previous_menu: Type[BaseMenu] | None) -> None:
|
||||||
@@ -152,39 +192,56 @@ class UpdateMenu(BaseMenu):
|
|||||||
print(menu, end="")
|
print(menu, end="")
|
||||||
|
|
||||||
def update_all(self, **kwargs) -> None:
|
def update_all(self, **kwargs) -> None:
|
||||||
print("update_all")
|
Logger.print_status("Updating all components ...")
|
||||||
|
self.update_klipper()
|
||||||
|
self.update_moonraker()
|
||||||
|
self.update_mainsail()
|
||||||
|
self.update_mainsail_config()
|
||||||
|
self.update_fluidd()
|
||||||
|
self.update_fluidd_config()
|
||||||
|
self.update_klipperscreen()
|
||||||
|
self.update_crowsnest()
|
||||||
|
self.upgrade_system_packages()
|
||||||
|
|
||||||
def update_klipper(self, **kwargs) -> None:
|
def update_klipper(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("klipper"):
|
self._run_update_routine("klipper", update_klipper)
|
||||||
update_klipper()
|
|
||||||
|
|
||||||
def update_moonraker(self, **kwargs) -> None:
|
def update_moonraker(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("moonraker"):
|
self._run_update_routine("moonraker", update_moonraker)
|
||||||
update_moonraker()
|
|
||||||
|
|
||||||
def update_mainsail(self, **kwargs) -> None:
|
def update_mainsail(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("mainsail"):
|
self._run_update_routine(
|
||||||
update_client(self.mainsail_data)
|
"mainsail",
|
||||||
|
update_client,
|
||||||
|
self.mainsail_data,
|
||||||
|
)
|
||||||
|
|
||||||
def update_mainsail_config(self, **kwargs) -> None:
|
def update_mainsail_config(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("mainsail_config"):
|
self._run_update_routine(
|
||||||
update_client_config(self.mainsail_data)
|
"mainsail_config",
|
||||||
|
update_client_config,
|
||||||
|
self.mainsail_data,
|
||||||
|
)
|
||||||
|
|
||||||
def update_fluidd(self, **kwargs) -> None:
|
def update_fluidd(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("fluidd"):
|
self._run_update_routine(
|
||||||
update_client(self.fluidd_data)
|
"fluidd",
|
||||||
|
update_client,
|
||||||
|
self.fluidd_data,
|
||||||
|
)
|
||||||
|
|
||||||
def update_fluidd_config(self, **kwargs) -> None:
|
def update_fluidd_config(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("fluidd_config"):
|
self._run_update_routine(
|
||||||
update_client_config(self.fluidd_data)
|
"fluidd_config",
|
||||||
|
update_client_config,
|
||||||
|
self.fluidd_data,
|
||||||
|
)
|
||||||
|
|
||||||
def update_klipperscreen(self, **kwargs) -> None:
|
def update_klipperscreen(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("klipperscreen"):
|
self._run_update_routine("klipperscreen", update_klipperscreen)
|
||||||
update_klipperscreen()
|
|
||||||
|
|
||||||
def update_crowsnest(self, **kwargs) -> None:
|
def update_crowsnest(self, **kwargs) -> None:
|
||||||
if self._check_is_installed("crowsnest"):
|
self._run_update_routine("crowsnest", update_crowsnest)
|
||||||
update_crowsnest()
|
|
||||||
|
|
||||||
def upgrade_system_packages(self, **kwargs) -> None:
|
def upgrade_system_packages(self, **kwargs) -> None:
|
||||||
self._run_system_updates()
|
self._run_system_updates()
|
||||||
@@ -239,10 +296,24 @@ class UpdateMenu(BaseMenu):
|
|||||||
setattr(self, f"{name}_remote", remote_txt)
|
setattr(self, f"{name}_remote", remote_txt)
|
||||||
|
|
||||||
def _check_is_installed(self, name: str) -> bool:
|
def _check_is_installed(self, name: str) -> bool:
|
||||||
if not self.status_data[name]["installed"]:
|
return self.status_data[name]["installed"]
|
||||||
Logger.print_info(f"{name.capitalize()} is not installed! Skipped ...")
|
|
||||||
return False
|
def _is_update_available(self, name: str) -> bool:
|
||||||
return True
|
return self.status_data[name]["local"] != self.status_data[name]["remote"]
|
||||||
|
|
||||||
|
def _run_update_routine(self, name: str, update_fn: Callable, *args) -> None:
|
||||||
|
display_name = self.status_data[name]["display_name"]
|
||||||
|
is_installed = self._check_is_installed(name)
|
||||||
|
is_update_available = self._is_update_available(name)
|
||||||
|
|
||||||
|
if not is_installed:
|
||||||
|
Logger.print_info(f"{display_name} is not installed! Skipped ...")
|
||||||
|
return
|
||||||
|
elif not is_update_available:
|
||||||
|
Logger.print_info(f"{display_name} is already up to date! Skipped ...")
|
||||||
|
return
|
||||||
|
|
||||||
|
update_fn(*args)
|
||||||
|
|
||||||
def _run_system_updates(self) -> None:
|
def _run_system_updates(self) -> None:
|
||||||
if not self.packages:
|
if not self.packages:
|
||||||
|
|||||||
@@ -177,3 +177,9 @@ def moonraker_exists(name: str = "") -> bool:
|
|||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def trunc_string(input_str: str, length: int) -> str:
|
||||||
|
if len(input_str) > length:
|
||||||
|
return f"{input_str[:length - 3]}..."
|
||||||
|
return input_str
|
||||||
|
|||||||
Reference in New Issue
Block a user