mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 08:43:36 +05:00
feat: implement crowsnest (#462)
* feat: add crowsnest install/remove Signed-off-by: Dominik Willner <th33xitus@gmail.com> * feat: add crowsnest update Signed-off-by: Dominik Willner <th33xitus@gmail.com> --------- Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
import textwrap
|
||||
from typing import Type, Optional
|
||||
|
||||
from components.crowsnest.crowsnest import install_crowsnest
|
||||
from components.klipper import klipper_setup
|
||||
from components.moonraker import moonraker_setup
|
||||
from components.webui_client import client_setup
|
||||
@@ -44,6 +45,7 @@ class InstallMenu(BaseMenu):
|
||||
"4": Option(method=self.install_fluidd, menu=False),
|
||||
"5": Option(method=self.install_mainsail_config, menu=False),
|
||||
"6": Option(method=self.install_fluidd_config, menu=False),
|
||||
"9": Option(method=self.install_crowsnest, menu=False),
|
||||
}
|
||||
|
||||
def print_menu(self):
|
||||
@@ -88,3 +90,6 @@ class InstallMenu(BaseMenu):
|
||||
|
||||
def install_fluidd_config(self, **kwargs):
|
||||
client_config_setup.install_client_config(FluiddData())
|
||||
|
||||
def install_crowsnest(self, **kwargs):
|
||||
install_crowsnest()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import textwrap
|
||||
from typing import Type, Optional
|
||||
|
||||
from components.crowsnest.crowsnest import get_crowsnest_status
|
||||
from components.klipper.klipper_utils import get_klipper_status
|
||||
from components.log_uploads.menus.log_upload_menu import LogUploadMenu
|
||||
from components.moonraker.moonraker_utils import get_moonraker_status
|
||||
@@ -90,16 +91,23 @@ class MainMenu(BaseMenu):
|
||||
self.ms_status = get_client_status(MainsailData())
|
||||
self.fl_status = get_client_status(FluiddData())
|
||||
self.cc_status = get_current_client_config([MainsailData(), FluiddData()])
|
||||
self._update_status("cn", get_crowsnest_status)
|
||||
|
||||
def _update_status(self, status_name: str, status_fn: callable) -> None:
|
||||
status_data = status_fn()
|
||||
status = status_data.get("status")
|
||||
code = status_data.get("status_code")
|
||||
instances = f" {status_data.get('instances')}" if code == 1 else ""
|
||||
|
||||
instance_count = status_data.get("instances")
|
||||
|
||||
count: str = ""
|
||||
if instance_count and code == 1:
|
||||
count = f" {instance_count}"
|
||||
|
||||
setattr(
|
||||
self,
|
||||
f"{status_name}_status",
|
||||
self._format_status_by_code(code, status, instances),
|
||||
self._format_status_by_code(code, status, count),
|
||||
)
|
||||
setattr(
|
||||
self,
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import textwrap
|
||||
from typing import Type, Optional
|
||||
|
||||
from components.crowsnest.crowsnest import remove_crowsnest
|
||||
from components.klipper.menus.klipper_remove_menu import KlipperRemoveMenu
|
||||
from components.moonraker.menus.moonraker_remove_menu import (
|
||||
MoonrakerRemoveMenu,
|
||||
@@ -42,6 +43,7 @@ class RemoveMenu(BaseMenu):
|
||||
"2": Option(method=self.remove_moonraker, menu=True),
|
||||
"3": Option(method=self.remove_mainsail, menu=True),
|
||||
"4": Option(method=self.remove_fluidd, menu=True),
|
||||
"6": Option(method=self.remove_crowsnest, menu=True),
|
||||
}
|
||||
|
||||
def print_menu(self):
|
||||
@@ -78,3 +80,6 @@ class RemoveMenu(BaseMenu):
|
||||
|
||||
def remove_fluidd(self, **kwargs):
|
||||
ClientRemoveMenu(previous_menu=self.__class__, client=FluiddData()).run()
|
||||
|
||||
def remove_crowsnest(self, **kwargs):
|
||||
remove_crowsnest()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import textwrap
|
||||
from typing import Type, Optional
|
||||
|
||||
from components.crowsnest.crowsnest import get_crowsnest_status, update_crowsnest
|
||||
from components.klipper.klipper_setup import update_klipper
|
||||
from components.klipper.klipper_utils import (
|
||||
get_klipper_status,
|
||||
@@ -57,6 +58,8 @@ class UpdateMenu(BaseMenu):
|
||||
self.mc_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.fc_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.fc_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.cn_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.cn_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
|
||||
self.mainsail_client = MainsailData()
|
||||
self.fluidd_client = FluiddData()
|
||||
@@ -111,7 +114,7 @@ class UpdateMenu(BaseMenu):
|
||||
| Other: |---------------|---------------|
|
||||
| 7) KlipperScreen | | |
|
||||
| 8) Mobileraker | | |
|
||||
| 9) Crowsnest | | |
|
||||
| 9) Crowsnest | {self.cn_local:<22} | {self.cn_remote:<22} |
|
||||
| |-------------------------------|
|
||||
| 10) System | |
|
||||
"""
|
||||
@@ -143,7 +146,8 @@ class UpdateMenu(BaseMenu):
|
||||
|
||||
def update_mobileraker(self, **kwargs): ...
|
||||
|
||||
def update_crowsnest(self, **kwargs): ...
|
||||
def update_crowsnest(self, **kwargs):
|
||||
update_crowsnest()
|
||||
|
||||
def upgrade_system_packages(self, **kwargs): ...
|
||||
|
||||
@@ -189,6 +193,13 @@ class UpdateMenu(BaseMenu):
|
||||
)
|
||||
self.fc_remote = f"{COLOR_GREEN}{fc_status.get('remote')}{RESET_FORMAT}"
|
||||
|
||||
# crowsnest
|
||||
cn_status = get_crowsnest_status()
|
||||
self.cn_local = self.format_local_status(
|
||||
cn_status.get("local"), cn_status.get("remote")
|
||||
)
|
||||
self.cn_remote = f"{COLOR_GREEN}{cn_status.get('remote')}{RESET_FORMAT}"
|
||||
|
||||
def format_local_status(self, local_version, remote_version) -> str:
|
||||
if local_version == remote_version:
|
||||
return f"{COLOR_GREEN}{local_version}{RESET_FORMAT}"
|
||||
|
||||
Reference in New Issue
Block a user