mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 08:43:36 +05:00
feat: add util function to check if moonraker is installed
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -20,7 +20,7 @@ from utils.constants import (
|
|||||||
RESET_FORMAT,
|
RESET_FORMAT,
|
||||||
)
|
)
|
||||||
from utils.git_utils import get_local_commit, get_remote_commit, get_repo_name
|
from utils.git_utils import get_local_commit, get_remote_commit, get_repo_name
|
||||||
from utils.logger import Logger
|
from utils.logger import DialogType, Logger
|
||||||
from utils.sys_utils import (
|
from utils.sys_utils import (
|
||||||
check_package_install,
|
check_package_install,
|
||||||
install_system_packages,
|
install_system_packages,
|
||||||
@@ -124,3 +124,33 @@ def backup_printer_config_dir():
|
|||||||
source=instance.cfg_dir,
|
source=instance.cfg_dir,
|
||||||
target=PRINTER_CFG_BACKUP_DIR,
|
target=PRINTER_CFG_BACKUP_DIR,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def moonraker_exists(name: str = "") -> bool:
|
||||||
|
"""
|
||||||
|
Helper method to check if a Moonraker instance exists
|
||||||
|
:param name: Optional name of an installer where the check is performed
|
||||||
|
:return: True if at least one Moonraker instance exists, False otherwise
|
||||||
|
"""
|
||||||
|
from components.moonraker.moonraker import Moonraker
|
||||||
|
|
||||||
|
mr_im = InstanceManager(Moonraker)
|
||||||
|
mr_instances: List[Moonraker] = mr_im.instances
|
||||||
|
|
||||||
|
info = (
|
||||||
|
f"{name} requires Moonraker to be installed"
|
||||||
|
if name
|
||||||
|
else "A Moonraker installation is required"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not mr_instances:
|
||||||
|
Logger.print_dialog(
|
||||||
|
DialogType.WARNING,
|
||||||
|
[
|
||||||
|
"No Moonraker instances found!",
|
||||||
|
f"{info}. Please install Moonraker first!",
|
||||||
|
],
|
||||||
|
end="",
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user