Compare commits

..

1 Commits

Author SHA1 Message Date
dw-0
6637f07067 Merge 7ec055f562 into b6c6edb622 2024-03-21 16:34:28 +01:00
53 changed files with 140 additions and 68 deletions

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #
@@ -10,6 +12,7 @@
from pathlib import Path
from components.webui_client.client_utils import (
get_existing_client_config,
get_existing_clients,
)
from kiauh import KIAUH_CFG

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #
@@ -13,6 +15,7 @@ import re
import shutil
import subprocess
import textwrap
from pathlib import Path
from typing import List, Union, Literal, Dict, Optional
from components.klipper import (

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #
@@ -10,11 +12,13 @@
import subprocess
import sys
from pathlib import Path
from typing import List
from components.webui_client import MAINSAIL_DIR
from components.webui_client.client_utils import enable_mainsail_remotemode, get_existing_clients
from kiauh import KIAUH_CFG
from components.klipper.klipper import Klipper
from components.klipper.klipper_dialogs import print_instance_overview
from components.moonraker import (
EXIT_MOONRAKER_SETUP,
DEFAULT_MOONRAKER_REPO_URL,

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #
@@ -19,18 +21,16 @@ from components.webui_client import ClientConfigData, ClientName, ClientData
from components.webui_client.client_dialogs import print_client_already_installed_dialog
from components.webui_client.client_utils import (
load_client_data,
backup_client_config_data,
config_for_other_client_exist,
)
backup_client_config_data, config_for_other_client_exist,
)
from core.config_manager.config_manager import ConfigManager
from core.instance_manager.instance_manager import InstanceManager
from core.repo_manager.repo_manager import RepoManager
from utils.common import backup_printer_config_dir
from utils.filesystem_utils import (
create_symlink,
add_config_section, add_config_section_at_top,
)
add_config_section,
)
from utils.input_utils import get_confirm
from utils.logger import Logger
@@ -59,9 +59,6 @@ def install_client_config(client_name: ClientName) -> None:
try:
download_client_config(client_config)
create_client_config_symlink(client_config, kl_instances)
backup_printer_config_dir()
add_config_section(
section=f"update_manager {client_config.get('name')}",
instances=mr_instances,
@@ -73,9 +70,7 @@ def install_client_config(client_name: ClientName) -> None:
("managed_services", "klipper"),
],
)
add_config_section_at_top(
client_config.get("printer_cfg_section"), kl_instances
)
add_config_section(client_config.get("printer_cfg_section"), kl_instances)
kl_im.restart_all_instance()
except Exception as e:

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #
@@ -30,9 +32,8 @@ from components.webui_client.client_utils import (
restore_mainsail_config_json,
enable_mainsail_remotemode,
symlink_webui_nginx_log,
load_client_data,
config_for_other_client_exist,
)
load_client_data, config_for_other_client_exist,
)
from core.config_manager.config_manager import ConfigManager
from core.instance_manager.instance_manager import InstanceManager
from kiauh import KIAUH_CFG

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #
@@ -7,13 +9,14 @@
# This file may be distributed under the terms of the GNU GPLv3 license #
# ======================================================================= #
from __future__ import annotations
from abc import abstractmethod, ABC
from pathlib import Path
from typing import List, Optional
from typing import List, Type, TypeVar
from utils.constants import SYSTEMD, CURRENT_USER
B = TypeVar(name="B", bound="BaseInstance", covariant=True)
class BaseInstance(ABC):
@classmethod
@@ -23,7 +26,7 @@ class BaseInstance(ABC):
def __init__(
self,
suffix: str,
instance_type: BaseInstance,
instance_type: B = B,
):
self._instance_type = instance_type
self._suffix = suffix
@@ -37,11 +40,11 @@ class BaseInstance(ABC):
self._gcodes_dir = self.data_dir.joinpath("gcodes")
@property
def instance_type(self) -> BaseInstance:
def instance_type(self) -> Type["BaseInstance"]:
return self._instance_type
@instance_type.setter
def instance_type(self, value: BaseInstance) -> None:
def instance_type(self, value: Type["BaseInstance"]) -> None:
self._instance_type = value
@property
@@ -73,7 +76,7 @@ class BaseInstance(ABC):
return self._data_dir
@data_dir.setter
def data_dir(self, value: Path) -> None:
def data_dir(self, value: str) -> None:
self._data_dir = value
@property
@@ -81,7 +84,7 @@ class BaseInstance(ABC):
return self._cfg_dir
@cfg_dir.setter
def cfg_dir(self, value: Path) -> None:
def cfg_dir(self, value: str) -> None:
self._cfg_dir = value
@property
@@ -89,7 +92,7 @@ class BaseInstance(ABC):
return self._log_dir
@log_dir.setter
def log_dir(self, value: Path) -> None:
def log_dir(self, value: str) -> None:
self._log_dir = value
@property
@@ -97,7 +100,7 @@ class BaseInstance(ABC):
return self._comms_dir
@comms_dir.setter
def comms_dir(self, value: Path) -> None:
def comms_dir(self, value: str) -> None:
self._comms_dir = value
@property
@@ -105,7 +108,7 @@ class BaseInstance(ABC):
return self._sysd_dir
@sysd_dir.setter
def sysd_dir(self, value: Path) -> None:
def sysd_dir(self, value: str) -> None:
self._sysd_dir = value
@property
@@ -113,7 +116,7 @@ class BaseInstance(ABC):
return self._gcodes_dir
@gcodes_dir.setter
def gcodes_dir(self, value: Path) -> None:
def gcodes_dir(self, value: str) -> None:
self._gcodes_dir = value
@abstractmethod
@@ -124,7 +127,7 @@ class BaseInstance(ABC):
def delete(self) -> None:
raise NotImplementedError("Subclasses must implement the delete method")
def create_folders(self, add_dirs: Optional[List[Path]] = None) -> None:
def create_folders(self, add_dirs: List[Path] = None) -> None:
dirs = [
self.data_dir,
self.cfg_dir,

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #
@@ -27,18 +29,14 @@ class AdvancedMenu(BaseMenu):
/=======================================================\\
| {color}{header:~^{count}}{RESET_FORMAT} |
|-------------------------------------------------------|
| Repo Rollback: |
| 1) [Klipper] |
| 2) [Moonraker] |
| |
| Klipper Firmware: |
| 3) [Build] |
| 4) [Flash] |
| 5) [Build + Flash] |
| 6) [Get MCU ID] |
| |
| Mainsail: |
| 7) [Theme installer] |
| Klipper & API: | Mainsail: |
| 0) [Rollback] | 5) [Theme installer] |
| | |
| Firmware: | System: |
| 1) [Build only] | 6) [Change hostname] |
| 2) [Flash only] | |
| 3) [Build + Flash] | Extras: |
| 4) [Get MCU ID] | 7) [G-Code Shell Command] |
"""
)[1:]
print(menu, end="")

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env python3
import os
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
@@ -13,15 +12,15 @@ import os
import re
import shutil
import subprocess
import tempfile
from pathlib import Path
from zipfile import ZipFile
from typing import List, TypeVar, Tuple, Optional
from typing import List, Type, TypeVar, Union, Tuple
from components.klipper.klipper import Klipper
from components.moonraker.moonraker import Moonraker
from core.config_manager.config_manager import ConfigManager
from core.instance_manager.base_instance import BaseInstance
from core.instance_manager.instance_manager import InstanceManager
from utils import (
NGINX_SITES_AVAILABLE,
@@ -32,7 +31,7 @@ from utils import (
from utils.logger import Logger
B = TypeVar("B", Klipper, Moonraker)
B = TypeVar('B', bound='BaseInstance')
ConfigOption = Tuple[str, str]
@@ -183,11 +182,7 @@ def get_next_free_port(ports_in_use: List[str]) -> str:
return str(min(valid_ports - used_ports))
def add_config_section(
section: str,
instances: List[B],
options: Optional[List[ConfigOption]] = None,
) -> None:
def add_config_section(section: str, instances: List[B], options: List[ConfigOption] = None) -> None:
for instance in instances:
cfg_file = instance.cfg_file
Logger.print_status(f"Add section '[{section}]' to '{cfg_file}' ...")
@@ -209,26 +204,6 @@ def add_config_section(
cm.write_config()
def add_config_section_at_top(
section: str,
instances: List[B]):
for instance in instances:
tmp_cfg = tempfile.NamedTemporaryFile(mode="w" ,delete=False)
tmp_cfg_path = Path(tmp_cfg.name)
cmt = ConfigManager(tmp_cfg_path)
cmt.config.add_section(section)
cmt.write_config()
tmp_cfg.close()
cfg_file = instance.cfg_file
with open(cfg_file, "r") as org:
org_content = org.readlines()
with open(tmp_cfg_path, "a") as tmp:
tmp.writelines(org_content)
cfg_file.unlink()
tmp_cfg_path.rename(cfg_file)
def remove_config_section(section: str, instances: List[B]) -> None:
for instance in instances:

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #

View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# ======================================================================= #
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
# #