fix(webclients): add symlink to added klipper instances
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from components.webui_client.client_utils import get_existing_client_config
|
||||
from components.webui_client.client_utils import get_existing_client_config, get_existing_clients
|
||||
from kiauh import KIAUH_CFG
|
||||
from components.klipper import (
|
||||
EXIT_KLIPPER_SETUP,
|
||||
@@ -182,6 +182,6 @@ def create_klipper_instance(name: str, create_example_cfg: bool) -> None:
|
||||
kl_im.enable_instance()
|
||||
if create_example_cfg:
|
||||
# if a client-config is installed, include it in the new example cfg
|
||||
client_configs = get_existing_client_config()
|
||||
create_example_printer_cfg(new_instance, client_configs)
|
||||
clients = get_existing_clients()
|
||||
create_example_printer_cfg(new_instance, clients)
|
||||
kl_im.start_instance()
|
||||
|
||||
@@ -34,6 +34,7 @@ from components.klipper.klipper_dialogs import (
|
||||
from components.moonraker.moonraker import Moonraker
|
||||
from components.moonraker.moonraker_utils import moonraker_to_multi_conversion
|
||||
from components.webui_client import ClientData
|
||||
from components.webui_client.client_config.client_config_setup import create_client_config_symlink
|
||||
from core.backup_manager.backup_manager import BackupManager
|
||||
from core.config_manager.config_manager import ConfigManager
|
||||
from core.instance_manager.base_instance import BaseInstance
|
||||
@@ -263,7 +264,7 @@ def get_highest_index(instance_list: List[Klipper]) -> int:
|
||||
|
||||
|
||||
def create_example_printer_cfg(
|
||||
instance: Klipper, client_configs: Optional[List[ClientData]] = None
|
||||
instance: Klipper, clients: Optional[List[ClientData]] = None
|
||||
) -> None:
|
||||
Logger.print_status(f"Creating example printer.cfg in '{instance.cfg_dir}'")
|
||||
if instance.cfg_file.is_file():
|
||||
@@ -282,10 +283,12 @@ def create_example_printer_cfg(
|
||||
cm.set_value("virtual_sdcard", "path", str(instance.gcodes_dir))
|
||||
|
||||
# include existing client configs in the example config
|
||||
if client_configs is not None and len(client_configs) > 0:
|
||||
for c in client_configs:
|
||||
section = c.get("client_config").get("printer_cfg_section")
|
||||
if clients is not None and len(clients) > 0:
|
||||
for c in clients:
|
||||
client_config = c.get("client_config")
|
||||
section = client_config.get("printer_cfg_section")
|
||||
cm.config.add_section(section=section)
|
||||
create_client_config_symlink(client_config,[instance])
|
||||
|
||||
cm.write_config()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user