mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 16:53:36 +05:00
refactor(KIAUH): full refactor of client and client-config installation
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -12,11 +12,15 @@
|
||||
import textwrap
|
||||
|
||||
from components.klipper.klipper_utils import backup_klipper_dir
|
||||
from components.mainsail.mainsail_utils import backup_mainsail_data
|
||||
from components.moonraker.moonraker_utils import (
|
||||
backup_moonraker_dir,
|
||||
backup_moonraker_db_dir,
|
||||
)
|
||||
from components.webui_client.client_utils import (
|
||||
backup_client_data,
|
||||
load_client_data,
|
||||
backup_client_config_data,
|
||||
)
|
||||
from core.menus import BACK_FOOTER
|
||||
from core.menus.base_menu import BaseMenu
|
||||
from utils.common import backup_printer_config_dir
|
||||
@@ -35,6 +39,10 @@ class BackupMenu(BaseMenu):
|
||||
"3": self.backup_printer_config,
|
||||
"4": self.backup_moonraker_db,
|
||||
"5": self.backup_mainsail,
|
||||
"6": self.backup_fluidd,
|
||||
"7": self.backup_mainsail_config,
|
||||
"8": self.backup_fluidd_config,
|
||||
"9": self.backup_klipperscreen,
|
||||
},
|
||||
footer_type=BACK_FOOTER,
|
||||
)
|
||||
@@ -51,15 +59,15 @@ class BackupMenu(BaseMenu):
|
||||
|-------------------------------------------------------|
|
||||
| {line1:^62} |
|
||||
|-------------------------------------------------------|
|
||||
| Klipper & Moonraker API: | Touchscreen GUI: |
|
||||
| 1) [Klipper] | 7) [KlipperScreen] |
|
||||
| 2) [Moonraker] | |
|
||||
| 3) [Config Folder] | Other: |
|
||||
| 4) [Moonraker Database] | 9) [Telegram Bot] |
|
||||
| | |
|
||||
| Klipper Webinterface: | |
|
||||
| 5) [Mainsail] | |
|
||||
| 6) [Fluidd] | |
|
||||
| Klipper & Moonraker API: | Client-Config: |
|
||||
| 1) [Klipper] | 7) [Mainsail-Config] |
|
||||
| 2) [Moonraker] | 8) [Fluidd-Config] |
|
||||
| 3) [Config Folder] | |
|
||||
| 4) [Moonraker Database] | Touchscreen GUI: |
|
||||
| | 9) [KlipperScreen] |
|
||||
| Webinterface: | |
|
||||
| 5) [Mainsail] | |
|
||||
| 6) [Fluidd] | |
|
||||
"""
|
||||
)[1:]
|
||||
print(menu, end="")
|
||||
@@ -77,13 +85,16 @@ class BackupMenu(BaseMenu):
|
||||
backup_moonraker_db_dir()
|
||||
|
||||
def backup_mainsail(self, **kwargs):
|
||||
backup_mainsail_data()
|
||||
backup_client_data(load_client_data("mainsail"))
|
||||
|
||||
def backup_fluidd(self, **kwargs):
|
||||
pass
|
||||
backup_client_data(load_client_data("fluidd"))
|
||||
|
||||
def backup_mainsail_config(self, **kwargs):
|
||||
backup_client_config_data(load_client_data("mainsail"))
|
||||
|
||||
def backup_fluidd_config(self, **kwargs):
|
||||
backup_client_config_data(load_client_data("fluidd"))
|
||||
|
||||
def backup_klipperscreen(self, **kwargs):
|
||||
pass
|
||||
|
||||
def backup_telegram_bot(self, **kwargs):
|
||||
pass
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
import textwrap
|
||||
|
||||
from components.fluidd import fluidd_setup
|
||||
from components.klipper import klipper_setup
|
||||
from components.mainsail import mainsail_setup
|
||||
from components.moonraker import moonraker_setup
|
||||
from components.webui_client import client_setup
|
||||
from components.webui_client.client_config import client_config_setup
|
||||
from core.menus import BACK_FOOTER
|
||||
from core.menus.base_menu import BaseMenu
|
||||
from utils.constants import COLOR_GREEN, RESET_FORMAT
|
||||
@@ -31,13 +31,11 @@ class InstallMenu(BaseMenu):
|
||||
"2": self.install_moonraker,
|
||||
"3": self.install_mainsail,
|
||||
"4": self.install_fluidd,
|
||||
"5": self.install_klipperscreen,
|
||||
"6": self.install_pretty_gcode,
|
||||
"7": self.install_telegram_bot,
|
||||
"8": self.install_obico,
|
||||
"9": self.install_octoeverywhere,
|
||||
"10": self.install_mobileraker,
|
||||
"11": self.install_crowsnest,
|
||||
"5": self.install_mainsail_config,
|
||||
"6": self.install_fluidd_config,
|
||||
"7": None,
|
||||
"8": None,
|
||||
"9": None,
|
||||
},
|
||||
footer_type=BACK_FOOTER,
|
||||
)
|
||||
@@ -51,16 +49,18 @@ class InstallMenu(BaseMenu):
|
||||
/=======================================================\\
|
||||
| {color}{header:~^{count}}{RESET_FORMAT} |
|
||||
|-------------------------------------------------------|
|
||||
| Firmware & API: | Other: |
|
||||
| 1) [Klipper] | 6) [PrettyGCode] |
|
||||
| 2) [Moonraker] | 7) [Telegram Bot] |
|
||||
| | 8) $(obico_install_title) |
|
||||
| Klipper Webinterface: | 9) [OctoEverywhere] |
|
||||
| 3) [Mainsail] | 10) [Mobileraker] |
|
||||
| 4) [Fluidd] | |
|
||||
| | Webcam Streamer: |
|
||||
| Touchscreen GUI: | 11) [Crowsnest] |
|
||||
| 5) [KlipperScreen] | |
|
||||
| Firmware & API: | Touchscreen GUI: |
|
||||
| 1) [Klipper] | 7) [KlipperScreen] |
|
||||
| 2) [Moonraker] | |
|
||||
| | Android / iOS: |
|
||||
| Webinterface: | 8) [Mobileraker] |
|
||||
| 3) [Mainsail] | |
|
||||
| 4) [Fluidd] | Webcam Streamer: |
|
||||
| | 9) [Crowsnest] |
|
||||
| Client-Config: | |
|
||||
| 5) [Mainsail-Config] | |
|
||||
| 6) [Fluidd-Config] | |
|
||||
| | |
|
||||
"""
|
||||
)[1:]
|
||||
print(menu, end="")
|
||||
@@ -72,28 +72,13 @@ class InstallMenu(BaseMenu):
|
||||
moonraker_setup.install_moonraker()
|
||||
|
||||
def install_mainsail(self, **kwargs):
|
||||
mainsail_setup.install_mainsail()
|
||||
client_setup.install_client(client_name="mainsail")
|
||||
|
||||
def install_mainsail_config(self, **kwargs):
|
||||
client_config_setup.install_client_config(client_name="mainsail")
|
||||
|
||||
def install_fluidd(self, **kwargs):
|
||||
fluidd_setup.install_fluidd()
|
||||
client_setup.install_client(client_name="fluidd")
|
||||
|
||||
def install_klipperscreen(self, **kwargs):
|
||||
print("install_klipperscreen")
|
||||
|
||||
def install_pretty_gcode(self, **kwargs):
|
||||
print("install_pretty_gcode")
|
||||
|
||||
def install_telegram_bot(self, **kwargs):
|
||||
print("install_telegram_bot")
|
||||
|
||||
def install_obico(self, **kwargs):
|
||||
print("install_obico")
|
||||
|
||||
def install_octoeverywhere(self, **kwargs):
|
||||
print("install_octoeverywhere")
|
||||
|
||||
def install_mobileraker(self, **kwargs):
|
||||
print("install_mobileraker")
|
||||
|
||||
def install_crowsnest(self, **kwargs):
|
||||
print("install_crowsnest")
|
||||
def install_fluidd_config(self, **kwargs):
|
||||
client_config_setup.install_client_config(client_name="fluidd")
|
||||
|
||||
@@ -11,11 +11,14 @@
|
||||
|
||||
import textwrap
|
||||
|
||||
from components.fluidd.fluidd_utils import get_fluidd_status
|
||||
from components.klipper.klipper_utils import get_klipper_status
|
||||
from components.log_uploads.menus.log_upload_menu import LogUploadMenu
|
||||
from components.mainsail.mainsail_utils import get_mainsail_status
|
||||
from components.moonraker.moonraker_utils import get_moonraker_status
|
||||
from components.webui_client.client_utils import (
|
||||
get_client_status,
|
||||
load_client_data,
|
||||
get_current_client_config,
|
||||
)
|
||||
from core.menus import QUIT_FOOTER
|
||||
from core.menus.advanced_menu import AdvancedMenu
|
||||
from core.menus.backup_menu import BackupMenu
|
||||
@@ -61,13 +64,11 @@ class MainMenu(BaseMenu):
|
||||
self.ks_status = ""
|
||||
self.mb_status = ""
|
||||
self.cn_status = ""
|
||||
self.tg_status = ""
|
||||
self.ob_status = ""
|
||||
self.oe_status = ""
|
||||
self.cc_status = ""
|
||||
self.init_status()
|
||||
|
||||
def init_status(self) -> None:
|
||||
status_vars = ["kl", "mr", "ms", "fl", "ks", "mb", "cn", "tg", "ob", "oe"]
|
||||
status_vars = ["kl", "mr", "ms", "fl", "ks", "mb", "cn"]
|
||||
for var in status_vars:
|
||||
setattr(self, f"{var}_status", f"{COLOR_RED}Not installed!{RESET_FORMAT}")
|
||||
|
||||
@@ -87,9 +88,15 @@ class MainMenu(BaseMenu):
|
||||
self.mr_status = self.format_status_by_code(mr_code, mr_status, mr_instances)
|
||||
self.mr_repo = f"{COLOR_CYAN}{moonraker_status.get('repo')}{RESET_FORMAT}"
|
||||
# mainsail
|
||||
self.ms_status = get_mainsail_status()
|
||||
mainsail_client_data = load_client_data("mainsail")
|
||||
self.ms_status = get_client_status(mainsail_client_data)
|
||||
# fluidd
|
||||
self.fl_status = get_fluidd_status()
|
||||
fluidd_client_data = load_client_data("fluidd")
|
||||
self.fl_status = get_client_status(fluidd_client_data)
|
||||
# client-config
|
||||
self.cc_status = get_current_client_config(
|
||||
[mainsail_client_data, fluidd_client_data]
|
||||
)
|
||||
|
||||
def format_status_by_code(self, code: int, status: str, count: str) -> str:
|
||||
if code == 1:
|
||||
@@ -120,13 +127,11 @@ class MainMenu(BaseMenu):
|
||||
| 4) [Advanced] |------------------------------------|
|
||||
| 5) [Backup] | Mainsail: {self.ms_status:<26} |
|
||||
| | Fluidd: {self.fl_status:<26} |
|
||||
| E) [Extensions] | KlipperScreen: {self.ks_status:<26} |
|
||||
| | Mobileraker: {self.mb_status:<26} |
|
||||
| S) [Settings] | Client-Config: {self.cc_status:<26} |
|
||||
| | |
|
||||
| Community: | KlipperScreen: {self.ks_status:<26} |
|
||||
| E) [Extensions] | Mobileraker: {self.mb_status:<26} |
|
||||
| | Crowsnest: {self.cn_status:<26} |
|
||||
| | Telegram Bot: {self.tg_status:<26} |
|
||||
| | Obico: {self.ob_status:<26} |
|
||||
| S) [Settings] | OctoEverywhere: {self.oe_status:<26} |
|
||||
|-------------------------------------------------------|
|
||||
| {COLOR_CYAN}{footer1:^16}{RESET_FORMAT} | {footer2:^43} |
|
||||
"""
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
import textwrap
|
||||
|
||||
from components.fluidd.menus.fluidd_remove_menu import FluiddRemoveMenu
|
||||
from components.klipper.menus.klipper_remove_menu import KlipperRemoveMenu
|
||||
from components.mainsail.menus.mainsail_remove_menu import MainsailRemoveMenu
|
||||
from components.moonraker.menus.moonraker_remove_menu import MoonrakerRemoveMenu
|
||||
from components.webui_client.client_utils import load_client_data
|
||||
from components.webui_client.menus.client_remove_menu import ClientRemoveMenu
|
||||
from core.menus import BACK_FOOTER
|
||||
from core.menus.base_menu import BaseMenu
|
||||
from utils.constants import COLOR_RED, RESET_FORMAT
|
||||
@@ -29,8 +29,8 @@ class RemoveMenu(BaseMenu):
|
||||
options={
|
||||
"1": KlipperRemoveMenu,
|
||||
"2": MoonrakerRemoveMenu,
|
||||
"3": MainsailRemoveMenu,
|
||||
"4": FluiddRemoveMenu,
|
||||
"3": ClientRemoveMenu(client=load_client_data("mainsail")),
|
||||
"4": ClientRemoveMenu(client=load_client_data("fluidd")),
|
||||
"5": None,
|
||||
"6": None,
|
||||
"7": None,
|
||||
|
||||
@@ -11,22 +11,22 @@
|
||||
|
||||
import textwrap
|
||||
|
||||
from components.fluidd.fluidd_setup import update_fluidd
|
||||
from components.fluidd.fluidd_utils import (
|
||||
get_fluidd_local_version,
|
||||
get_fluidd_remote_version,
|
||||
)
|
||||
from components.klipper.klipper_setup import update_klipper
|
||||
from components.klipper.klipper_utils import (
|
||||
get_klipper_status,
|
||||
)
|
||||
from components.mainsail.mainsail_setup import update_mainsail
|
||||
from components.mainsail.mainsail_utils import (
|
||||
get_mainsail_local_version,
|
||||
get_mainsail_remote_version,
|
||||
)
|
||||
from components.moonraker.moonraker_setup import update_moonraker
|
||||
from components.moonraker.moonraker_utils import get_moonraker_status
|
||||
from components.webui_client.client_config.client_config_setup import (
|
||||
update_client_config,
|
||||
)
|
||||
from components.webui_client.client_setup import update_client
|
||||
from components.webui_client.client_utils import (
|
||||
get_local_client_version,
|
||||
get_remote_client_version,
|
||||
load_client_data,
|
||||
get_client_config_status,
|
||||
)
|
||||
from core.menus import BACK_FOOTER
|
||||
from core.menus.base_menu import BaseMenu
|
||||
from utils.constants import (
|
||||
@@ -50,14 +50,12 @@ class UpdateMenu(BaseMenu):
|
||||
"2": self.update_moonraker,
|
||||
"3": self.update_mainsail,
|
||||
"4": self.update_fluidd,
|
||||
"5": self.update_klipperscreen,
|
||||
"6": self.update_pgc_for_klipper,
|
||||
"7": self.update_telegram_bot,
|
||||
"8": self.update_moonraker_obico,
|
||||
"9": self.update_octoeverywhere,
|
||||
"10": self.update_mobileraker,
|
||||
"11": self.update_crowsnest,
|
||||
"12": self.upgrade_system_packages,
|
||||
"5": self.update_mainsail_config,
|
||||
"6": self.update_fluidd_config,
|
||||
"7": self.update_klipperscreen,
|
||||
"8": self.update_mobileraker,
|
||||
"9": self.update_crowsnest,
|
||||
"10": self.upgrade_system_packages,
|
||||
},
|
||||
footer_type=BACK_FOOTER,
|
||||
)
|
||||
@@ -69,6 +67,10 @@ class UpdateMenu(BaseMenu):
|
||||
self.ms_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.fl_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.fl_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.mc_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.mc_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.fc_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
self.fc_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||
|
||||
def print_menu(self):
|
||||
self.fetch_update_status()
|
||||
@@ -87,22 +89,20 @@ class UpdateMenu(BaseMenu):
|
||||
| 1) Klipper | {self.kl_local:<22} | {self.kl_remote:<22} |
|
||||
| 2) Moonraker | {self.mr_local:<22} | {self.mr_remote:<22} |
|
||||
| | | |
|
||||
| Klipper Webinterface: |---------------|---------------|
|
||||
| Webinterface: |---------------|---------------|
|
||||
| 3) Mainsail | {self.ms_local:<22} | {self.ms_remote:<22} |
|
||||
| 4) Fluidd | {self.fl_local:<22} | {self.fl_remote:<22} |
|
||||
| | | |
|
||||
| Touchscreen GUI: |---------------|---------------|
|
||||
| 5) KlipperScreen | | |
|
||||
| Client-Config: |---------------|---------------|
|
||||
| 5) Mainsail-Config | {self.mc_local:<22} | {self.mc_remote:<22} |
|
||||
| 6) Fluidd-Config | {self.fc_local:<22} | {self.fc_remote:<22} |
|
||||
| | | |
|
||||
| Other: |---------------|---------------|
|
||||
| 6) PrettyGCode | | |
|
||||
| 7) Telegram Bot | | |
|
||||
| 8) Obico for Klipper | | |
|
||||
| 9) OctoEverywhere | | |
|
||||
| 10) Mobileraker | | |
|
||||
| 11) Crowsnest | | |
|
||||
| 7) KlipperScreen | | |
|
||||
| 8) Mobileraker | | |
|
||||
| 9) Crowsnest | | |
|
||||
| |-------------------------------|
|
||||
| 12) System | |
|
||||
| 10) System | |
|
||||
"""
|
||||
)[1:]
|
||||
print(menu, end="")
|
||||
@@ -117,34 +117,24 @@ class UpdateMenu(BaseMenu):
|
||||
update_moonraker()
|
||||
|
||||
def update_mainsail(self, **kwargs):
|
||||
update_mainsail()
|
||||
update_client(load_client_data("mainsail"))
|
||||
|
||||
def update_mainsail_config(self, **kwargs):
|
||||
update_client_config(load_client_data("mainsail"))
|
||||
|
||||
def update_fluidd(self, **kwargs):
|
||||
update_fluidd()
|
||||
update_client(load_client_data("fluidd"))
|
||||
|
||||
def update_klipperscreen(self, **kwargs):
|
||||
print("update_klipperscreen")
|
||||
def update_fluidd_config(self, **kwargs):
|
||||
update_client_config(load_client_data("fluidd"))
|
||||
|
||||
def update_pgc_for_klipper(self, **kwargs):
|
||||
print("update_pgc_for_klipper")
|
||||
def update_klipperscreen(self, **kwargs): ...
|
||||
|
||||
def update_telegram_bot(self, **kwargs):
|
||||
print("update_telegram_bot")
|
||||
def update_mobileraker(self, **kwargs): ...
|
||||
|
||||
def update_moonraker_obico(self, **kwargs):
|
||||
print("update_moonraker_obico")
|
||||
def update_crowsnest(self, **kwargs): ...
|
||||
|
||||
def update_octoeverywhere(self, **kwargs):
|
||||
print("update_octoeverywhere")
|
||||
|
||||
def update_mobileraker(self, **kwargs):
|
||||
print("update_mobileraker")
|
||||
|
||||
def update_crowsnest(self, **kwargs):
|
||||
print("update_crowsnest")
|
||||
|
||||
def upgrade_system_packages(self, **kwargs):
|
||||
print("upgrade_system_packages")
|
||||
def upgrade_system_packages(self, **kwargs): ...
|
||||
|
||||
def fetch_update_status(self):
|
||||
# klipper
|
||||
@@ -166,18 +156,38 @@ class UpdateMenu(BaseMenu):
|
||||
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()
|
||||
mainsail_client_data = load_client_data("mainsail")
|
||||
self.ms_local = get_local_client_version(mainsail_client_data)
|
||||
self.ms_remote = get_remote_client_version(mainsail_client_data)
|
||||
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 if self.ms_remote != 'ERROR' else COLOR_RED}{self.ms_remote}{RESET_FORMAT}"
|
||||
# fluidd
|
||||
self.fl_local = get_fluidd_local_version()
|
||||
self.fl_remote = get_fluidd_remote_version()
|
||||
fluidd_client_data = load_client_data("fluidd")
|
||||
self.fl_local = get_local_client_version(fluidd_client_data)
|
||||
self.fl_remote = get_remote_client_version(fluidd_client_data)
|
||||
if self.fl_local == self.fl_remote:
|
||||
self.fl_local = f"{COLOR_GREEN}{self.fl_local}{RESET_FORMAT}"
|
||||
else:
|
||||
self.fl_local = f"{COLOR_YELLOW}{self.fl_local}{RESET_FORMAT}"
|
||||
self.fl_remote = f"{COLOR_GREEN if self.fl_remote != 'ERROR' else COLOR_RED}{self.fl_remote}{RESET_FORMAT}"
|
||||
# mainsail-config
|
||||
mc_status = get_client_config_status(load_client_data("mainsail"))
|
||||
self.mc_local = mc_status.get("local")
|
||||
self.mc_remote = mc_status.get("remote")
|
||||
if self.mc_local == self.mc_remote:
|
||||
self.mc_local = f"{COLOR_GREEN}{self.mc_local}{RESET_FORMAT}"
|
||||
else:
|
||||
self.mc_local = f"{COLOR_YELLOW}{self.mc_local}{RESET_FORMAT}"
|
||||
self.mc_remote = f"{COLOR_GREEN}{self.mc_remote}{RESET_FORMAT}"
|
||||
# fluidd-config
|
||||
fc_status = get_client_config_status(load_client_data("fluidd"))
|
||||
self.fc_local = fc_status.get("local")
|
||||
self.fc_remote = fc_status.get("remote")
|
||||
if self.fc_local == self.mc_remote:
|
||||
self.fc_local = f"{COLOR_GREEN}{self.fc_local}{RESET_FORMAT}"
|
||||
else:
|
||||
self.fc_local = f"{COLOR_YELLOW}{self.fc_local}{RESET_FORMAT}"
|
||||
self.fc_remote = f"{COLOR_GREEN}{self.fc_remote}{RESET_FORMAT}"
|
||||
|
||||
Reference in New Issue
Block a user