refactor: implement octoeverywhere update

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2024-06-28 20:01:46 +02:00
parent e06a4e3197
commit 3ec5e1a3b8
3 changed files with 26 additions and 14 deletions

View File

@@ -23,9 +23,12 @@ from components.octoeverywhere import (
)
from components.octoeverywhere.octoeverywhere import Octoeverywhere
from core.instance_manager.instance_manager import InstanceManager
from utils.common import check_install_dependencies, moonraker_exists
from utils.common import (
check_install_dependencies,
get_install_status,
moonraker_exists,
)
from utils.config_utils import (
add_config_section,
remove_config_section,
)
from utils.fs_utils import run_remove_routines
@@ -34,10 +37,14 @@ from utils.input_utils import get_confirm
from utils.logger import DialogType, Logger
from utils.sys_utils import (
cmd_sysctl_manage,
create_python_venv,
install_python_requirements,
parse_packages_from_file,
)
from utils.types import ComponentStatus
def get_octoeverywhere_status() -> ComponentStatus:
return get_install_status(OE_DIR, OE_ENV_DIR, Octoeverywhere)
def install_octoeverywhere() -> None:
@@ -89,7 +96,6 @@ def install_octoeverywhere() -> None:
try:
git_clone_wrapper(OE_REPO, OE_DIR)
install_oe_dependencies()
for moonraker in mr_instances:
oe_im.current_instance = Octoeverywhere(suffix=moonraker.suffix)
@@ -160,16 +166,9 @@ def install_oe_dependencies() -> None:
raise ValueError("Error reading OctoEverywhere dependencies!")
check_install_dependencies(oe_deps)
# create virtualenv
create_python_venv(OE_ENV_DIR)
install_python_requirements(OE_ENV_DIR, OE_REQ_FILE)
def patch_moonraker_conf(instances: List[Moonraker]) -> None:
add_config_section(section=f"include {OE_SYS_CFG_NAME}", instances=instances)
def remove_oe_instances(
instance_manager: InstanceManager,
instance_list: List[Octoeverywhere],

View File

@@ -16,6 +16,7 @@ from components.klipperscreen.klipperscreen import get_klipperscreen_status
from components.log_uploads.menus.log_upload_menu import LogUploadMenu
from components.mobileraker.mobileraker import get_mobileraker_status
from components.moonraker.moonraker_utils import get_moonraker_status
from components.octoeverywhere.octoeverywhere_setup import get_octoeverywhere_status
from components.webui_client.client_utils import (
get_client_status,
get_current_client_config,
@@ -91,6 +92,7 @@ class MainMenu(BaseMenu):
self._get_component_status("ks", get_klipperscreen_status)
self._get_component_status("mb", get_mobileraker_status)
self._get_component_status("cn", get_crowsnest_status)
self._get_component_status("oe", get_octoeverywhere_status)
def _get_component_status(self, name: str, status_fn: callable, *args) -> None:
status_data: ComponentStatus = status_fn(*args)

View File

@@ -25,6 +25,10 @@ from components.mobileraker.mobileraker import (
)
from components.moonraker.moonraker_setup import update_moonraker
from components.moonraker.moonraker_utils import get_moonraker_status
from components.octoeverywhere.octoeverywhere_setup import (
get_octoeverywhere_status,
update_octoeverywhere,
)
from components.webui_client.client_config.client_config_setup import (
update_client_config,
)
@@ -57,7 +61,7 @@ class UpdateMenu(BaseMenu):
self.ms_local = self.ms_remote = self.fl_local = self.fl_remote = ""
self.mc_local = self.mc_remote = self.fc_local = self.fc_remote = ""
self.ks_local = self.ks_remote = self.mb_local = self.mb_remote = ""
self.cn_local = self.cn_remote = ""
self.cn_local = self.cn_remote = self.oe_local = self.oe_remote = ""
self.mainsail_data = MainsailData()
self.fluidd_data = FluiddData()
@@ -82,7 +86,8 @@ class UpdateMenu(BaseMenu):
"7": Option(self.update_klipperscreen, menu=False),
"8": Option(self.update_mobileraker, menu=False),
"9": Option(self.update_crowsnest, menu=False),
"10": Option(self.upgrade_system_packages, menu=False),
"10": Option(self.update_octoeverywhere, menu=False),
"11": Option(self.upgrade_system_packages, menu=False),
}
def print_menu(self):
@@ -114,8 +119,9 @@ class UpdateMenu(BaseMenu):
║ 7) KlipperScreen │ {self.ks_local:<22}{self.ks_remote:<22}
║ 8) Mobileraker │ {self.mb_local:<22}{self.mb_remote:<22}
║ 9) Crowsnest │ {self.cn_local:<22}{self.cn_remote:<22}
║ 10) OctoEverywhere │ {self.oe_local:<22}{self.oe_remote:<22}
║ ├───────────────┴───────────────╢
║ 10) System │ ║
║ 11) System │ ║
╟───────────────────────┴───────────────────────────────╢
"""
)[1:]
@@ -151,6 +157,9 @@ class UpdateMenu(BaseMenu):
def update_crowsnest(self, **kwargs):
update_crowsnest()
def update_octoeverywhere(self, **kwargs):
update_octoeverywhere()
def upgrade_system_packages(self, **kwargs): ...
def _fetch_update_status(self):
@@ -172,6 +181,8 @@ class UpdateMenu(BaseMenu):
self._get_update_status("mb", get_mobileraker_status)
# crowsnest
self._get_update_status("cn", get_crowsnest_status)
# octoeverywhere
self._get_update_status("oe", get_octoeverywhere_status)
def _format_local_status(self, local_version, remote_version) -> str:
if local_version == remote_version: