mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-23 07:43:36 +05:00
Compare commits
5 Commits
05b4ef2d18
...
7fd91e6cef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fd91e6cef | ||
|
|
750cb7b307 | ||
|
|
384503c4f5 | ||
|
|
2a4fcf3a3a | ||
|
|
573dc7c3c9 |
@@ -12,5 +12,9 @@ branch: master
|
|||||||
method: https
|
method: https
|
||||||
|
|
||||||
[mainsail]
|
[mainsail]
|
||||||
default_port: 80
|
port: 80
|
||||||
|
unstable_releases: False
|
||||||
|
|
||||||
|
[fluidd]
|
||||||
|
port: 80
|
||||||
unstable_releases: False
|
unstable_releases: False
|
||||||
|
|||||||
@@ -9,7 +9,11 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
APPLICATION_ROOT = Path(__file__).resolve().parent.parent
|
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||||
KIAUH_CFG = APPLICATION_ROOT.joinpath("kiauh.cfg")
|
KIAUH_CFG = PROJECT_ROOT.joinpath("kiauh.cfg")
|
||||||
|
|
||||||
|
APPLICATION_ROOT = Path(__file__).resolve().parent
|
||||||
|
sys.path.append(str(APPLICATION_ROOT))
|
||||||
|
|||||||
26
kiauh/components/fluidd/__init__.py
Normal file
26
kiauh/components/fluidd/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
|
FLUIDD_DIR = Path.home().joinpath("fluidd")
|
||||||
|
FLUIDD_BACKUP_DIR = BACKUP_ROOT_DIR.joinpath("fluidd-backups")
|
||||||
|
FLUIDD_CONFIG_DIR = Path.home().joinpath("fluidd-config")
|
||||||
|
FLUIDD_NGINX_CFG = Path("/etc/nginx/sites-enabled/fluidd")
|
||||||
|
FLUIDD_URL = "https://github.com/fluidd-core/fluidd/releases/latest/download/fluidd.zip"
|
||||||
|
FLUIDD_UNSTABLE_URL = (
|
||||||
|
"https://github.com/fluidd-core/fluidd/releases/download/%TAG%/fluidd.zip"
|
||||||
|
)
|
||||||
|
FLUIDD_CONFIG_REPO_URL = "https://github.com/fluidd-core/fluidd-config.git"
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
[update_manager fluidd-config]
|
||||||
|
type: git_repo
|
||||||
|
primary_branch: master
|
||||||
|
path: ~/fluidd-config
|
||||||
|
origin: https://github.com/fluidd-core/fluidd-config.git
|
||||||
|
managed_services: klipper
|
||||||
5
kiauh/components/fluidd/assets/fluidd-updater.conf
Normal file
5
kiauh/components/fluidd/assets/fluidd-updater.conf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[update_manager fluidd]
|
||||||
|
type: web
|
||||||
|
channel: stable
|
||||||
|
repo: fluidd-core/fluidd
|
||||||
|
path: ~/fluidd
|
||||||
104
kiauh/components/fluidd/fluidd_dialogs.py
Normal file
104
kiauh/components/fluidd/fluidd_dialogs.py
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
import textwrap
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from core.menus.base_menu import print_back_footer
|
||||||
|
from utils.constants import RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
|
def print_moonraker_not_found_dialog():
|
||||||
|
line1 = f"{COLOR_YELLOW}WARNING:{RESET_FORMAT}"
|
||||||
|
line2 = f"{COLOR_YELLOW}No local Moonraker installation was found!{RESET_FORMAT}"
|
||||||
|
dialog = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
/=======================================================\\
|
||||||
|
| {line1:<63}|
|
||||||
|
| {line2:<63}|
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| It is possible to install Fluidd without a local |
|
||||||
|
| Moonraker installation. If you continue, you need to |
|
||||||
|
| make sure, that Moonraker is installed on another |
|
||||||
|
| machine in your network. Otherwise Fluidd will NOT |
|
||||||
|
| work correctly. |
|
||||||
|
"""
|
||||||
|
)[1:]
|
||||||
|
|
||||||
|
print(dialog, end="")
|
||||||
|
print_back_footer()
|
||||||
|
|
||||||
|
|
||||||
|
def print_fluidd_already_installed_dialog():
|
||||||
|
line1 = f"{COLOR_YELLOW}WARNING:{RESET_FORMAT}"
|
||||||
|
line2 = f"{COLOR_YELLOW}Fluidd seems to be already installed!{RESET_FORMAT}"
|
||||||
|
dialog = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
/=======================================================\\
|
||||||
|
| {line1:<63}|
|
||||||
|
| {line2:<63}|
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| If you continue, your current Fluidd installation |
|
||||||
|
| will be overwritten. You will not loose any printer |
|
||||||
|
| configurations and the Moonraker database will remain |
|
||||||
|
| untouched. |
|
||||||
|
"""
|
||||||
|
)[1:]
|
||||||
|
|
||||||
|
print(dialog, end="")
|
||||||
|
print_back_footer()
|
||||||
|
|
||||||
|
|
||||||
|
def print_install_fluidd_config_dialog():
|
||||||
|
dialog = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
/=======================================================\\
|
||||||
|
| It is recommended to use special macros in order to |
|
||||||
|
| have Fluidd fully functional and working. |
|
||||||
|
| |
|
||||||
|
| The recommended macros for Fluidd can be seen here: |
|
||||||
|
| https://github.com/fluidd-core/fluidd-config |
|
||||||
|
| |
|
||||||
|
| If you already use these macros skip this step. |
|
||||||
|
| Otherwise you should consider to answer with 'Y' to |
|
||||||
|
| download the recommended macros. |
|
||||||
|
\\=======================================================/
|
||||||
|
"""
|
||||||
|
)[1:]
|
||||||
|
|
||||||
|
print(dialog, end="")
|
||||||
|
|
||||||
|
|
||||||
|
def print_fluidd_port_select_dialog(port: str, ports_in_use: List[str]):
|
||||||
|
port = f"{COLOR_CYAN}{port}{RESET_FORMAT}"
|
||||||
|
dialog = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
/=======================================================\\
|
||||||
|
| Please select the port, Fluidd should be served on. |
|
||||||
|
| If you are unsure what to select, hit Enter to apply |
|
||||||
|
| the suggested value of: {port:38} |
|
||||||
|
| |
|
||||||
|
| In case you need Fluidd to be served on a specific |
|
||||||
|
| port, you can set it now. Make sure the port is not |
|
||||||
|
| used by any other application on your system! |
|
||||||
|
"""
|
||||||
|
)[1:]
|
||||||
|
|
||||||
|
if len(ports_in_use) > 0:
|
||||||
|
dialog += "|-------------------------------------------------------|\n"
|
||||||
|
dialog += "| The following ports were found to be in use already: |\n"
|
||||||
|
for port in ports_in_use:
|
||||||
|
port = f"{COLOR_CYAN}● {port}{RESET_FORMAT}"
|
||||||
|
dialog += f"| {port:60} |\n"
|
||||||
|
|
||||||
|
dialog += "\\=======================================================/\n"
|
||||||
|
|
||||||
|
print(dialog, end="")
|
||||||
160
kiauh/components/fluidd/fluidd_remove.py
Normal file
160
kiauh/components/fluidd/fluidd_remove.py
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from components.klipper.klipper import Klipper
|
||||||
|
from components.fluidd import FLUIDD_DIR, FLUIDD_CONFIG_DIR
|
||||||
|
from components.moonraker.moonraker import Moonraker
|
||||||
|
from core.config_manager.config_manager import ConfigManager
|
||||||
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
|
from utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
||||||
|
from utils.filesystem_utils import remove_file
|
||||||
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
|
def run_fluidd_removal(
|
||||||
|
remove_fluidd: bool,
|
||||||
|
remove_fl_config: bool,
|
||||||
|
remove_mr_updater_section: bool,
|
||||||
|
remove_flc_printer_cfg_include: bool,
|
||||||
|
) -> None:
|
||||||
|
if remove_fluidd:
|
||||||
|
remove_fluidd_dir()
|
||||||
|
remove_nginx_config()
|
||||||
|
remove_nginx_logs()
|
||||||
|
if remove_mr_updater_section:
|
||||||
|
remove_updater_section("update_manager fluidd")
|
||||||
|
if remove_fl_config:
|
||||||
|
remove_fluidd_cfg_dir()
|
||||||
|
remove_fluidd_cfg_symlink()
|
||||||
|
if remove_mr_updater_section:
|
||||||
|
remove_updater_section("update_manager fluidd-config")
|
||||||
|
if remove_flc_printer_cfg_include:
|
||||||
|
remove_printer_cfg_include()
|
||||||
|
|
||||||
|
|
||||||
|
def remove_fluidd_dir() -> None:
|
||||||
|
Logger.print_status("Removing Fluidd ...")
|
||||||
|
if not FLUIDD_DIR.exists():
|
||||||
|
Logger.print_info(f"'{FLUIDD_DIR}' does not exist. Skipping ...")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
shutil.rmtree(FLUIDD_DIR)
|
||||||
|
except OSError as e:
|
||||||
|
Logger.print_error(f"Unable to delete '{FLUIDD_DIR}':\n{e}")
|
||||||
|
|
||||||
|
|
||||||
|
def remove_nginx_config() -> None:
|
||||||
|
Logger.print_status("Removing Fluidd NGINX config ...")
|
||||||
|
try:
|
||||||
|
remove_file(NGINX_SITES_AVAILABLE.joinpath("fluidd"), True)
|
||||||
|
remove_file(NGINX_SITES_ENABLED.joinpath("fluidd"), True)
|
||||||
|
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
log = f"Unable to remove Fluidd NGINX config:\n{e.stderr.decode()}"
|
||||||
|
Logger.print_error(log)
|
||||||
|
|
||||||
|
|
||||||
|
def remove_nginx_logs() -> None:
|
||||||
|
Logger.print_status("Removing Fluidd NGINX logs ...")
|
||||||
|
try:
|
||||||
|
remove_file(Path("/var/log/nginx/fluidd-access.log"), True)
|
||||||
|
remove_file(Path("/var/log/nginx/fluidd-error.log"), True)
|
||||||
|
|
||||||
|
im = InstanceManager(Klipper)
|
||||||
|
instances: List[Klipper] = im.instances
|
||||||
|
if not instances:
|
||||||
|
return
|
||||||
|
|
||||||
|
for instance in instances:
|
||||||
|
remove_file(instance.log_dir.joinpath("fluidd-access.log"))
|
||||||
|
remove_file(instance.log_dir.joinpath("fluidd-error.log"))
|
||||||
|
|
||||||
|
except (OSError, subprocess.CalledProcessError) as e:
|
||||||
|
Logger.print_error(f"Unable to NGINX logs:\n{e}")
|
||||||
|
|
||||||
|
|
||||||
|
def remove_updater_section(name: str) -> None:
|
||||||
|
Logger.print_status("Remove updater section from moonraker.conf ...")
|
||||||
|
im = InstanceManager(Moonraker)
|
||||||
|
instances: List[Moonraker] = im.instances
|
||||||
|
if not instances:
|
||||||
|
Logger.print_info("Moonraker not installed. Skipped ...")
|
||||||
|
return
|
||||||
|
|
||||||
|
for instance in instances:
|
||||||
|
Logger.print_status(f"Remove section '{name}' in '{instance.cfg_file}' ...")
|
||||||
|
|
||||||
|
if not instance.cfg_file.is_file():
|
||||||
|
Logger.print_info(f"'{instance.cfg_file}' does not exist. Skipped ...")
|
||||||
|
continue
|
||||||
|
|
||||||
|
cm = ConfigManager(instance.cfg_file)
|
||||||
|
if not cm.config.has_section(name):
|
||||||
|
Logger.print_info("Section not present. Skipped ...")
|
||||||
|
continue
|
||||||
|
|
||||||
|
cm.config.remove_section(name)
|
||||||
|
cm.write_config()
|
||||||
|
|
||||||
|
|
||||||
|
def remove_fluidd_cfg_dir() -> None:
|
||||||
|
Logger.print_status("Removing fluidd-config ...")
|
||||||
|
if not FLUIDD_CONFIG_DIR.exists():
|
||||||
|
Logger.print_info(f"'{FLUIDD_CONFIG_DIR}' does not exist. Skipping ...")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
shutil.rmtree(FLUIDD_CONFIG_DIR)
|
||||||
|
except OSError as e:
|
||||||
|
Logger.print_error(f"Unable to delete '{FLUIDD_CONFIG_DIR}':\n{e}")
|
||||||
|
|
||||||
|
|
||||||
|
def remove_fluidd_cfg_symlink() -> None:
|
||||||
|
Logger.print_status("Removing fluidd.cfg symlinks ...")
|
||||||
|
im = InstanceManager(Klipper)
|
||||||
|
instances: List[Klipper] = im.instances
|
||||||
|
for instance in instances:
|
||||||
|
Logger.print_status(f"Removing symlink from '{instance.cfg_file}' ...")
|
||||||
|
try:
|
||||||
|
remove_file(instance.cfg_dir.joinpath("fluidd.cfg"))
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
Logger.print_error("Failed to remove symlink!")
|
||||||
|
|
||||||
|
|
||||||
|
def remove_printer_cfg_include() -> None:
|
||||||
|
Logger.print_status("Remove fluidd-config include from printer.cfg ...")
|
||||||
|
im = InstanceManager(Klipper)
|
||||||
|
instances: List[Klipper] = im.instances
|
||||||
|
if not instances:
|
||||||
|
Logger.print_info("Klipper not installed. Skipping ...")
|
||||||
|
return
|
||||||
|
|
||||||
|
for instance in instances:
|
||||||
|
log = f"Removing include from '{instance.cfg_file}' ..."
|
||||||
|
Logger.print_status(log)
|
||||||
|
|
||||||
|
if not instance.cfg_file.is_file():
|
||||||
|
continue
|
||||||
|
|
||||||
|
cm = ConfigManager(instance.cfg_file)
|
||||||
|
if not cm.config.has_section("include fluidd.cfg"):
|
||||||
|
Logger.print_info("Section not present. Skipped ...")
|
||||||
|
continue
|
||||||
|
|
||||||
|
cm.config.remove_section("include fluidd.cfg")
|
||||||
|
cm.write_config()
|
||||||
242
kiauh/components/fluidd/fluidd_setup.py
Normal file
242
kiauh/components/fluidd/fluidd_setup.py
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from components.fluidd import (
|
||||||
|
FLUIDD_URL,
|
||||||
|
FLUIDD_CONFIG_REPO_URL,
|
||||||
|
FLUIDD_CONFIG_DIR,
|
||||||
|
FLUIDD_DIR,
|
||||||
|
MODULE_PATH,
|
||||||
|
)
|
||||||
|
from components.fluidd.fluidd_dialogs import (
|
||||||
|
print_fluidd_already_installed_dialog,
|
||||||
|
print_install_fluidd_config_dialog,
|
||||||
|
print_fluidd_port_select_dialog,
|
||||||
|
print_moonraker_not_found_dialog,
|
||||||
|
)
|
||||||
|
from components.fluidd.fluidd_utils import symlink_webui_nginx_log
|
||||||
|
from kiauh import KIAUH_CFG
|
||||||
|
from components.klipper.klipper import Klipper
|
||||||
|
from components.moonraker.moonraker import Moonraker
|
||||||
|
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 import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
||||||
|
from utils.common import check_install_dependencies
|
||||||
|
from utils.filesystem_utils import (
|
||||||
|
unzip,
|
||||||
|
copy_upstream_nginx_cfg,
|
||||||
|
copy_common_vars_nginx_cfg,
|
||||||
|
create_nginx_cfg,
|
||||||
|
create_symlink,
|
||||||
|
remove_file,
|
||||||
|
read_ports_from_nginx_configs,
|
||||||
|
get_next_free_port, is_valid_port,
|
||||||
|
)
|
||||||
|
from utils.input_utils import get_confirm, get_number_input
|
||||||
|
from utils.logger import Logger
|
||||||
|
from utils.system_utils import (
|
||||||
|
download_file,
|
||||||
|
set_nginx_permissions,
|
||||||
|
get_ipv4_addr,
|
||||||
|
control_systemd_service,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def install_fluidd() -> None:
|
||||||
|
mr_im = InstanceManager(Moonraker)
|
||||||
|
mr_instances: List[Moonraker] = mr_im.instances
|
||||||
|
|
||||||
|
if not mr_instances:
|
||||||
|
print_moonraker_not_found_dialog()
|
||||||
|
if not get_confirm("Continue Fluidd installation?", allow_go_back=True):
|
||||||
|
return
|
||||||
|
|
||||||
|
if Path.home().joinpath("fluidd").exists():
|
||||||
|
print_fluidd_already_installed_dialog()
|
||||||
|
do_reinstall = get_confirm("Re-install Fluidd?", allow_go_back=True)
|
||||||
|
if not do_reinstall:
|
||||||
|
return
|
||||||
|
|
||||||
|
kl_im = InstanceManager(Klipper)
|
||||||
|
kl_instances = kl_im.instances
|
||||||
|
install_fl_config = False
|
||||||
|
if kl_instances:
|
||||||
|
print_install_fluidd_config_dialog()
|
||||||
|
question = "Download the recommended macros?"
|
||||||
|
install_fl_config = get_confirm(question, allow_go_back=False)
|
||||||
|
|
||||||
|
cm = ConfigManager(cfg_file=KIAUH_CFG)
|
||||||
|
fluidd_port = cm.get_value("fluidd", "port")
|
||||||
|
ports_in_use = read_ports_from_nginx_configs()
|
||||||
|
|
||||||
|
# check if configured port is a valid number and not in use already
|
||||||
|
valid_port = is_valid_port(fluidd_port, ports_in_use)
|
||||||
|
while not valid_port:
|
||||||
|
next_port = get_next_free_port(ports_in_use)
|
||||||
|
print_fluidd_port_select_dialog(next_port, ports_in_use)
|
||||||
|
fluidd_port = str(get_number_input(
|
||||||
|
"Configure Fluidd for port",
|
||||||
|
min_count=int(next_port),
|
||||||
|
default=next_port,
|
||||||
|
))
|
||||||
|
valid_port = is_valid_port(fluidd_port, ports_in_use)
|
||||||
|
|
||||||
|
check_install_dependencies(["nginx"])
|
||||||
|
|
||||||
|
try:
|
||||||
|
download_fluidd()
|
||||||
|
if mr_instances:
|
||||||
|
patch_moonraker_conf(
|
||||||
|
mr_instances,
|
||||||
|
"Fluidd",
|
||||||
|
"update_manager fluidd",
|
||||||
|
"fluidd-updater.conf",
|
||||||
|
)
|
||||||
|
mr_im.restart_all_instance()
|
||||||
|
if install_fl_config and kl_instances:
|
||||||
|
download_fluidd_cfg()
|
||||||
|
create_fluidd_cfg_symlink(kl_instances)
|
||||||
|
patch_moonraker_conf(
|
||||||
|
mr_instances,
|
||||||
|
"fluidd-config",
|
||||||
|
"update_manager fluidd-config",
|
||||||
|
"fluidd-config-updater.conf",
|
||||||
|
)
|
||||||
|
patch_printer_config(kl_instances)
|
||||||
|
kl_im.restart_all_instance()
|
||||||
|
|
||||||
|
copy_upstream_nginx_cfg()
|
||||||
|
copy_common_vars_nginx_cfg()
|
||||||
|
create_fluidd_nginx_cfg(fluidd_port)
|
||||||
|
if kl_instances:
|
||||||
|
symlink_webui_nginx_log(kl_instances)
|
||||||
|
control_systemd_service("nginx", "restart")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
Logger.print_error(f"Fluidd installation failed!\n{e}")
|
||||||
|
return
|
||||||
|
|
||||||
|
log = f"Open Fluidd now on: http://{get_ipv4_addr()}:{fluidd_port}"
|
||||||
|
Logger.print_ok("Fluidd installation complete!", start="\n")
|
||||||
|
Logger.print_ok(log, prefix=False, end="\n\n")
|
||||||
|
|
||||||
|
|
||||||
|
def download_fluidd() -> None:
|
||||||
|
try:
|
||||||
|
Logger.print_status("Downloading Fluidd ...")
|
||||||
|
target = Path.home().joinpath("fluidd.zip")
|
||||||
|
download_file(FLUIDD_URL, target, True)
|
||||||
|
Logger.print_ok("Download complete!")
|
||||||
|
|
||||||
|
Logger.print_status("Extracting fluidd.zip ...")
|
||||||
|
unzip(Path.home().joinpath("fluidd.zip"), FLUIDD_DIR)
|
||||||
|
target.unlink(missing_ok=True)
|
||||||
|
Logger.print_ok("OK!")
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
Logger.print_error("Downloading Fluidd failed!")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def update_fluidd() -> None:
|
||||||
|
Logger.print_status("Updating Fluidd ...")
|
||||||
|
download_fluidd()
|
||||||
|
|
||||||
|
|
||||||
|
def download_fluidd_cfg() -> None:
|
||||||
|
try:
|
||||||
|
Logger.print_status("Downloading fluidd-config ...")
|
||||||
|
rm = RepoManager(FLUIDD_CONFIG_REPO_URL, target_dir=FLUIDD_CONFIG_DIR)
|
||||||
|
rm.clone_repo()
|
||||||
|
except Exception:
|
||||||
|
Logger.print_error("Downloading fluidd-config failed!")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def create_fluidd_cfg_symlink(klipper_instances: List[Klipper]) -> None:
|
||||||
|
Logger.print_status("Create symlink of fluidd.cfg ...")
|
||||||
|
source = Path(FLUIDD_CONFIG_DIR, "fluidd.cfg")
|
||||||
|
for instance in klipper_instances:
|
||||||
|
target = instance.cfg_dir
|
||||||
|
Logger.print_status(f"Linking {source} to {target}")
|
||||||
|
try:
|
||||||
|
create_symlink(source, target)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
Logger.print_error("Creating symlink failed!")
|
||||||
|
|
||||||
|
|
||||||
|
def create_fluidd_nginx_cfg(port: int) -> None:
|
||||||
|
root_dir = FLUIDD_DIR
|
||||||
|
source = NGINX_SITES_AVAILABLE.joinpath("fluidd")
|
||||||
|
target = NGINX_SITES_ENABLED.joinpath("fluidd")
|
||||||
|
try:
|
||||||
|
Logger.print_status("Creating NGINX config for Fluidd ...")
|
||||||
|
remove_file(Path("/etc/nginx/sites-enabled/default"), True)
|
||||||
|
create_nginx_cfg("fluidd", port, root_dir)
|
||||||
|
create_symlink(source, target, True)
|
||||||
|
set_nginx_permissions()
|
||||||
|
Logger.print_ok("NGINX config for Fluidd successfully created.")
|
||||||
|
except Exception:
|
||||||
|
Logger.print_error("Creating NGINX config for Fluidd failed!")
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: could be fully extracted, its webui agnostic, and used for mainsail and fluidd
|
||||||
|
def patch_moonraker_conf(
|
||||||
|
moonraker_instances: List[Moonraker],
|
||||||
|
name: str,
|
||||||
|
section_name: str,
|
||||||
|
template_file: str,
|
||||||
|
) -> None:
|
||||||
|
for instance in moonraker_instances:
|
||||||
|
cfg_file = instance.cfg_file
|
||||||
|
Logger.print_status(f"Add {name} update section to '{cfg_file}' ...")
|
||||||
|
|
||||||
|
if not Path(cfg_file).exists():
|
||||||
|
Logger.print_warn(f"'{cfg_file}' not found!")
|
||||||
|
return
|
||||||
|
|
||||||
|
cm = ConfigManager(cfg_file)
|
||||||
|
if cm.config.has_section(section_name):
|
||||||
|
Logger.print_info("Section already exist. Skipped ...")
|
||||||
|
return
|
||||||
|
|
||||||
|
template = MODULE_PATH.joinpath("assets", template_file)
|
||||||
|
with open(template, "r") as t:
|
||||||
|
template_content = "\n"
|
||||||
|
template_content += t.read()
|
||||||
|
|
||||||
|
with open(cfg_file, "a") as f:
|
||||||
|
f.write(template_content)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: could be made fully webui agnostic and extracted, and used for mainsail and fluidd
|
||||||
|
def patch_printer_config(klipper_instances: List[Klipper]) -> None:
|
||||||
|
for instance in klipper_instances:
|
||||||
|
cfg_file = instance.cfg_file
|
||||||
|
Logger.print_status(f"Including fluidd-config in '{cfg_file}' ...")
|
||||||
|
|
||||||
|
if not Path(cfg_file).exists():
|
||||||
|
Logger.print_warn(f"'{cfg_file}' not found!")
|
||||||
|
return
|
||||||
|
|
||||||
|
cm = ConfigManager(cfg_file)
|
||||||
|
if cm.config.has_section("include fluidd.cfg"):
|
||||||
|
Logger.print_info("Section already exist. Skipped ...")
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(cfg_file, "a") as f:
|
||||||
|
f.write("\n[include fluidd.cfg]")
|
||||||
79
kiauh/components/fluidd/fluidd_utils.py
Normal file
79
kiauh/components/fluidd/fluidd_utils.py
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
import json
|
||||||
|
import urllib.request
|
||||||
|
from json import JSONDecodeError
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from components.fluidd import FLUIDD_DIR, FLUIDD_BACKUP_DIR
|
||||||
|
from components.klipper.klipper import Klipper
|
||||||
|
from core.backup_manager.backup_manager import BackupManager
|
||||||
|
from utils import NGINX_SITES_AVAILABLE, NGINX_CONFD
|
||||||
|
from utils.common import get_install_status_webui
|
||||||
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: could be extracted and made generic
|
||||||
|
def get_fluidd_status() -> str:
|
||||||
|
return get_install_status_webui(
|
||||||
|
FLUIDD_DIR,
|
||||||
|
NGINX_SITES_AVAILABLE.joinpath("fluidd"),
|
||||||
|
NGINX_CONFD.joinpath("upstreams.conf"),
|
||||||
|
NGINX_CONFD.joinpath("common_vars.conf"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: could be extracted and made generic
|
||||||
|
def symlink_webui_nginx_log(klipper_instances: List[Klipper]) -> None:
|
||||||
|
Logger.print_status("Link NGINX logs into log directory ...")
|
||||||
|
access_log = Path("/var/log/nginx/fluidd-access.log")
|
||||||
|
error_log = Path("/var/log/nginx/fluidd-error.log")
|
||||||
|
|
||||||
|
for instance in klipper_instances:
|
||||||
|
desti_access = instance.log_dir.joinpath("fluidd-access.log")
|
||||||
|
if not desti_access.exists():
|
||||||
|
desti_access.symlink_to(access_log)
|
||||||
|
|
||||||
|
desti_error = instance.log_dir.joinpath("fluidd-error.log")
|
||||||
|
if not desti_error.exists():
|
||||||
|
desti_error.symlink_to(error_log)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: could be extracted and made generic
|
||||||
|
def get_fluidd_local_version() -> str:
|
||||||
|
relinfo_file = FLUIDD_DIR.joinpath("release_info.json")
|
||||||
|
if not relinfo_file.is_file():
|
||||||
|
return "-"
|
||||||
|
|
||||||
|
with open(relinfo_file, "r") as f:
|
||||||
|
return json.load(f)["version"]
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: could be extracted and made generic
|
||||||
|
def get_fluidd_remote_version() -> str:
|
||||||
|
url = "https://api.github.com/repos/fluidd-core/fluidd/tags"
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(url) as response:
|
||||||
|
data = json.loads(response.read())
|
||||||
|
return data[0]["name"]
|
||||||
|
except (JSONDecodeError, TypeError):
|
||||||
|
return "ERROR"
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: could be extracted and made generic
|
||||||
|
def backup_fluidd_data() -> None:
|
||||||
|
with open(FLUIDD_DIR.joinpath(".version"), "r") as v:
|
||||||
|
version = v.readlines()[0]
|
||||||
|
bm = BackupManager()
|
||||||
|
bm.backup_directory(f"fluidd-{version}", FLUIDD_DIR, FLUIDD_BACKUP_DIR)
|
||||||
|
bm.backup_file(NGINX_SITES_AVAILABLE.joinpath("fluidd"), FLUIDD_BACKUP_DIR)
|
||||||
0
kiauh/components/fluidd/menus/__init__.py
Normal file
0
kiauh/components/fluidd/menus/__init__.py
Normal file
111
kiauh/components/fluidd/menus/fluidd_remove_menu.py
Normal file
111
kiauh/components/fluidd/menus/fluidd_remove_menu.py
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# ======================================================================= #
|
||||||
|
# Copyright (C) 2020 - 2024 Dominik Willner <th33xitus@gmail.com> #
|
||||||
|
# #
|
||||||
|
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||||
|
# https://github.com/dw-0/kiauh #
|
||||||
|
# #
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
|
# ======================================================================= #
|
||||||
|
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
from components.fluidd import fluidd_remove
|
||||||
|
from core.menus import BACK_HELP_FOOTER
|
||||||
|
from core.menus.base_menu import BaseMenu
|
||||||
|
from utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
|
# noinspection PyUnusedLocal
|
||||||
|
class FluiddRemoveMenu(BaseMenu):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(
|
||||||
|
header=False,
|
||||||
|
options={
|
||||||
|
"0": self.toggle_all,
|
||||||
|
"1": self.toggle_remove_fluidd,
|
||||||
|
"2": self.toggle_remove_fl_config,
|
||||||
|
"3": self.toggle_remove_updater_section,
|
||||||
|
"4": self.toggle_remove_printer_cfg_include,
|
||||||
|
"5": self.run_removal_process,
|
||||||
|
},
|
||||||
|
footer_type=BACK_HELP_FOOTER,
|
||||||
|
)
|
||||||
|
self.remove_fluidd = False
|
||||||
|
self.remove_fl_config = False
|
||||||
|
self.remove_updater_section = False
|
||||||
|
self.remove_printer_cfg_include = False
|
||||||
|
|
||||||
|
def print_menu(self) -> None:
|
||||||
|
header = " [ Remove Fluidd ] "
|
||||||
|
color = COLOR_RED
|
||||||
|
count = 62 - len(color) - len(RESET_FORMAT)
|
||||||
|
checked = f"[{COLOR_CYAN}x{RESET_FORMAT}]"
|
||||||
|
unchecked = "[ ]"
|
||||||
|
o1 = checked if self.remove_fluidd else unchecked
|
||||||
|
o2 = checked if self.remove_fl_config else unchecked
|
||||||
|
o3 = checked if self.remove_updater_section else unchecked
|
||||||
|
o4 = checked if self.remove_printer_cfg_include else unchecked
|
||||||
|
menu = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
/=======================================================\\
|
||||||
|
| {color}{header:~^{count}}{RESET_FORMAT} |
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| Enter a number and hit enter to select / deselect |
|
||||||
|
| the specific option for removal. |
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| 0) Select everything |
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| 1) {o1} Remove Fluidd |
|
||||||
|
| 2) {o2} Remove fluidd-config |
|
||||||
|
| |
|
||||||
|
| printer.cfg & moonraker.conf |
|
||||||
|
| 3) {o3} Remove Moonraker update section |
|
||||||
|
| 4) {o4} Remove printer.cfg include |
|
||||||
|
|-------------------------------------------------------|
|
||||||
|
| 5) Continue |
|
||||||
|
"""
|
||||||
|
)[1:]
|
||||||
|
print(menu, end="")
|
||||||
|
|
||||||
|
def toggle_all(self, **kwargs) -> None:
|
||||||
|
self.remove_fluidd = True
|
||||||
|
self.remove_fl_config = True
|
||||||
|
self.remove_updater_section = True
|
||||||
|
self.remove_printer_cfg_include = True
|
||||||
|
|
||||||
|
def toggle_remove_fluidd(self, **kwargs) -> None:
|
||||||
|
self.remove_fluidd = not self.remove_fluidd
|
||||||
|
|
||||||
|
def toggle_remove_fl_config(self, **kwargs) -> None:
|
||||||
|
self.remove_fl_config = not self.remove_fl_config
|
||||||
|
|
||||||
|
def toggle_remove_updater_section(self, **kwargs) -> None:
|
||||||
|
self.remove_updater_section = not self.remove_updater_section
|
||||||
|
|
||||||
|
def toggle_remove_printer_cfg_include(self, **kwargs) -> None:
|
||||||
|
self.remove_printer_cfg_include = not self.remove_printer_cfg_include
|
||||||
|
|
||||||
|
def run_removal_process(self, **kwargs) -> None:
|
||||||
|
if (
|
||||||
|
not self.remove_fluidd
|
||||||
|
and not self.remove_fl_config
|
||||||
|
and not self.remove_updater_section
|
||||||
|
and not self.remove_printer_cfg_include
|
||||||
|
):
|
||||||
|
error = f"{COLOR_RED}Nothing selected! Select options to remove first.{RESET_FORMAT}"
|
||||||
|
print(error)
|
||||||
|
return
|
||||||
|
|
||||||
|
fluidd_remove.run_fluidd_removal(
|
||||||
|
remove_fluidd=self.remove_fluidd,
|
||||||
|
remove_fl_config=self.remove_fl_config,
|
||||||
|
remove_mr_updater_section=self.remove_updater_section,
|
||||||
|
remove_flc_printer_cfg_include=self.remove_printer_cfg_include,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.remove_fluidd = False
|
||||||
|
self.remove_fl_config = False
|
||||||
|
self.remove_updater_section = False
|
||||||
|
self.remove_printer_cfg_include = False
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
from core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR, MODULE_PATH
|
from components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR, MODULE_PATH
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.utils.constants import SYSTEMD
|
from utils.constants import SYSTEMD
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.core.menus.base_menu import print_back_footer
|
from core.menus.base_menu import print_back_footer
|
||||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
from utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
def print_instance_overview(
|
def print_instance_overview(
|
||||||
|
|||||||
@@ -12,13 +12,13 @@
|
|||||||
import shutil
|
import shutil
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
from kiauh.components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR
|
from components.klipper import KLIPPER_DIR, KLIPPER_ENV_DIR
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
from components.klipper.klipper_dialogs import print_instance_overview
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils.filesystem_utils import remove_file
|
from utils.filesystem_utils import remove_file
|
||||||
from kiauh.utils.input_utils import get_selection_input
|
from utils.input_utils import get_selection_input
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def run_klipper_removal(
|
def run_klipper_removal(
|
||||||
|
|||||||
@@ -12,16 +12,16 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiauh import KIAUH_CFG
|
from kiauh import KIAUH_CFG
|
||||||
from kiauh.components.klipper import (
|
from components.klipper import (
|
||||||
EXIT_KLIPPER_SETUP,
|
EXIT_KLIPPER_SETUP,
|
||||||
DEFAULT_KLIPPER_REPO_URL,
|
DEFAULT_KLIPPER_REPO_URL,
|
||||||
KLIPPER_DIR,
|
KLIPPER_DIR,
|
||||||
KLIPPER_ENV_DIR,
|
KLIPPER_ENV_DIR,
|
||||||
KLIPPER_REQUIREMENTS_TXT,
|
KLIPPER_REQUIREMENTS_TXT,
|
||||||
)
|
)
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.klipper.klipper_dialogs import print_update_warn_dialog
|
from components.klipper.klipper_dialogs import print_update_warn_dialog
|
||||||
from kiauh.components.klipper.klipper_utils import (
|
from components.klipper.klipper_utils import (
|
||||||
handle_disruptive_system_packages,
|
handle_disruptive_system_packages,
|
||||||
check_user_groups,
|
check_user_groups,
|
||||||
handle_to_multi_instance_conversion,
|
handle_to_multi_instance_conversion,
|
||||||
@@ -34,13 +34,13 @@ from kiauh.components.klipper.klipper_utils import (
|
|||||||
handle_instance_naming,
|
handle_instance_naming,
|
||||||
backup_klipper_dir,
|
backup_klipper_dir,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
from core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.input_utils import get_confirm
|
from utils.input_utils import get_confirm
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import (
|
from utils.system_utils import (
|
||||||
parse_packages_from_file,
|
parse_packages_from_file,
|
||||||
create_python_venv,
|
create_python_venv,
|
||||||
install_python_requirements,
|
install_python_requirements,
|
||||||
|
|||||||
@@ -18,32 +18,32 @@ import textwrap
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Union, Literal, Dict
|
from typing import List, Union, Literal, Dict
|
||||||
|
|
||||||
from kiauh.components.klipper import (
|
from components.klipper import (
|
||||||
MODULE_PATH,
|
MODULE_PATH,
|
||||||
KLIPPER_DIR,
|
KLIPPER_DIR,
|
||||||
KLIPPER_ENV_DIR,
|
KLIPPER_ENV_DIR,
|
||||||
KLIPPER_BACKUP_DIR,
|
KLIPPER_BACKUP_DIR,
|
||||||
)
|
)
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.klipper.klipper_dialogs import (
|
from components.klipper.klipper_dialogs import (
|
||||||
print_missing_usergroup_dialog,
|
print_missing_usergroup_dialog,
|
||||||
print_instance_overview,
|
print_instance_overview,
|
||||||
print_select_instance_count_dialog,
|
print_select_instance_count_dialog,
|
||||||
print_select_custom_name_dialog,
|
print_select_custom_name_dialog,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.components.moonraker.moonraker_utils import moonraker_to_multi_conversion
|
from components.moonraker.moonraker_utils import moonraker_to_multi_conversion
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
from core.backup_manager.backup_manager import BackupManager
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.core.instance_manager.name_scheme import NameScheme
|
from core.instance_manager.name_scheme import NameScheme
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
from core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.common import get_install_status_common
|
from utils.common import get_install_status_common
|
||||||
from kiauh.utils.constants import CURRENT_USER
|
from utils.constants import CURRENT_USER
|
||||||
from kiauh.utils.input_utils import get_confirm, get_string_input, get_number_input
|
from utils.input_utils import get_confirm, get_string_input, get_number_input
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import mask_system_service
|
from utils.system_utils import mask_system_service
|
||||||
|
|
||||||
|
|
||||||
def get_klipper_status() -> Dict[
|
def get_klipper_status() -> Dict[
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.klipper import klipper_remove
|
from components.klipper import klipper_remove
|
||||||
from kiauh.core.menus import BACK_HELP_FOOTER
|
from core.menus import BACK_HELP_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
from utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import urllib.request
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.log_uploads import LogFile
|
from components.log_uploads import LogFile
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def get_logfile_list() -> List[LogFile]:
|
def get_logfile_list() -> List[LogFile]:
|
||||||
|
|||||||
@@ -11,11 +11,11 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.log_uploads.log_upload_utils import get_logfile_list
|
from components.log_uploads.log_upload_utils import get_logfile_list
|
||||||
from kiauh.components.log_uploads.log_upload_utils import upload_logfile
|
from components.log_uploads.log_upload_utils import upload_logfile
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from core.menus import BACK_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_YELLOW
|
from utils.constants import RESET_FORMAT, COLOR_YELLOW
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
from core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
MAINSAIL_DIR = Path.home().joinpath("mainsail")
|
MAINSAIL_DIR = Path.home().joinpath("mainsail")
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.core.menus.base_menu import print_back_footer
|
from core.menus.base_menu import print_back_footer
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
from utils.constants import RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
def print_moonraker_not_found_dialog():
|
def print_moonraker_not_found_dialog():
|
||||||
|
|||||||
@@ -15,15 +15,15 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.mainsail import MAINSAIL_DIR, MAINSAIL_CONFIG_DIR
|
from components.mainsail import MAINSAIL_DIR, MAINSAIL_CONFIG_DIR
|
||||||
from kiauh.components.mainsail.mainsail_utils import backup_config_json
|
from components.mainsail.mainsail_utils import backup_config_json
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
from utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
||||||
from kiauh.utils.filesystem_utils import remove_file
|
from utils.filesystem_utils import remove_file
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def run_mainsail_removal(
|
def run_mainsail_removal(
|
||||||
|
|||||||
@@ -14,33 +14,33 @@ from pathlib import Path
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh import KIAUH_CFG
|
from kiauh import KIAUH_CFG
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.mainsail import (
|
from components.mainsail import (
|
||||||
MAINSAIL_URL,
|
MAINSAIL_URL,
|
||||||
MAINSAIL_DIR,
|
MAINSAIL_DIR,
|
||||||
MAINSAIL_CONFIG_DIR,
|
MAINSAIL_CONFIG_DIR,
|
||||||
MAINSAIL_CONFIG_REPO_URL,
|
MAINSAIL_CONFIG_REPO_URL,
|
||||||
MODULE_PATH,
|
MODULE_PATH,
|
||||||
)
|
)
|
||||||
from kiauh.components.mainsail.mainsail_dialogs import (
|
from components.mainsail.mainsail_dialogs import (
|
||||||
print_moonraker_not_found_dialog,
|
print_moonraker_not_found_dialog,
|
||||||
print_mainsail_already_installed_dialog,
|
print_mainsail_already_installed_dialog,
|
||||||
print_install_mainsail_config_dialog,
|
print_install_mainsail_config_dialog,
|
||||||
print_mainsail_port_select_dialog,
|
print_mainsail_port_select_dialog,
|
||||||
)
|
)
|
||||||
from kiauh.components.mainsail.mainsail_utils import (
|
from components.mainsail.mainsail_utils import (
|
||||||
restore_config_json,
|
restore_config_json,
|
||||||
enable_mainsail_remotemode,
|
enable_mainsail_remotemode,
|
||||||
backup_config_json,
|
backup_config_json,
|
||||||
symlink_webui_nginx_log,
|
symlink_webui_nginx_log,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
from core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
from utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED
|
||||||
from kiauh.utils.common import check_install_dependencies
|
from utils.common import check_install_dependencies
|
||||||
from kiauh.utils.filesystem_utils import (
|
from utils.filesystem_utils import (
|
||||||
unzip,
|
unzip,
|
||||||
copy_upstream_nginx_cfg,
|
copy_upstream_nginx_cfg,
|
||||||
copy_common_vars_nginx_cfg,
|
copy_common_vars_nginx_cfg,
|
||||||
@@ -48,9 +48,9 @@ from kiauh.utils.filesystem_utils import (
|
|||||||
create_symlink,
|
create_symlink,
|
||||||
remove_file,
|
remove_file,
|
||||||
)
|
)
|
||||||
from kiauh.utils.input_utils import get_confirm, get_number_input
|
from utils.input_utils import get_confirm, get_number_input
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import (
|
from utils.system_utils import (
|
||||||
download_file,
|
download_file,
|
||||||
set_nginx_permissions,
|
set_nginx_permissions,
|
||||||
get_ipv4_addr,
|
get_ipv4_addr,
|
||||||
|
|||||||
@@ -11,21 +11,22 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import shutil
|
import shutil
|
||||||
|
from json import JSONDecodeError
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import requests
|
import urllib.request
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.mainsail import (
|
from components.mainsail import (
|
||||||
MAINSAIL_CONFIG_JSON,
|
MAINSAIL_CONFIG_JSON,
|
||||||
MAINSAIL_DIR,
|
MAINSAIL_DIR,
|
||||||
MAINSAIL_BACKUP_DIR,
|
MAINSAIL_BACKUP_DIR,
|
||||||
)
|
)
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
from core.backup_manager.backup_manager import BackupManager
|
||||||
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_CONFD
|
from utils import NGINX_SITES_AVAILABLE, NGINX_CONFD
|
||||||
from kiauh.utils.common import get_install_status_webui
|
from utils.common import get_install_status_webui
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def get_mainsail_status() -> str:
|
def get_mainsail_status() -> str:
|
||||||
@@ -99,9 +100,12 @@ def get_mainsail_local_version() -> str:
|
|||||||
|
|
||||||
def get_mainsail_remote_version() -> str:
|
def get_mainsail_remote_version() -> str:
|
||||||
url = "https://api.github.com/repos/mainsail-crew/mainsail/tags"
|
url = "https://api.github.com/repos/mainsail-crew/mainsail/tags"
|
||||||
response = requests.get(url)
|
try:
|
||||||
data = json.loads(response.text)
|
with urllib.request.urlopen(url) as response:
|
||||||
return data[0]["name"]
|
data = json.loads(response.read())
|
||||||
|
return data[0]["name"]
|
||||||
|
except (JSONDecodeError, TypeError):
|
||||||
|
return "ERROR"
|
||||||
|
|
||||||
|
|
||||||
def backup_mainsail_data() -> None:
|
def backup_mainsail_data() -> None:
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.mainsail import mainsail_remove
|
from components.mainsail import mainsail_remove
|
||||||
from kiauh.core.menus import BACK_HELP_FOOTER
|
from core.menus import BACK_HELP_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
from utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
from core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.moonraker import moonraker_remove
|
from components.moonraker import moonraker_remove
|
||||||
from kiauh.core.menus import BACK_HELP_FOOTER
|
from core.menus import BACK_HELP_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
from utils.constants import RESET_FORMAT, COLOR_RED, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
from kiauh.components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR, MODULE_PATH
|
from components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR, MODULE_PATH
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.utils.constants import SYSTEMD
|
from utils.constants import SYSTEMD
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
import textwrap
|
import textwrap
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.core.menus.base_menu import print_back_footer
|
from core.menus.base_menu import print_back_footer
|
||||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
from utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_CYAN
|
||||||
|
|
||||||
|
|
||||||
def print_moonraker_overview(
|
def print_moonraker_overview(
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
from components.klipper.klipper_dialogs import print_instance_overview
|
||||||
from kiauh.components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR
|
from components.moonraker import MOONRAKER_DIR, MOONRAKER_ENV_DIR
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils.filesystem_utils import remove_file
|
from utils.filesystem_utils import remove_file
|
||||||
from kiauh.utils.input_utils import get_selection_input
|
from utils.input_utils import get_selection_input
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def run_moonraker_removal(
|
def run_moonraker_removal(
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ from pathlib import Path
|
|||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh import KIAUH_CFG
|
from kiauh import KIAUH_CFG
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.components.klipper.klipper_dialogs import print_instance_overview
|
from components.klipper.klipper_dialogs import print_instance_overview
|
||||||
from kiauh.components.mainsail import MAINSAIL_DIR
|
from components.mainsail import MAINSAIL_DIR
|
||||||
from kiauh.components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
from components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
||||||
from kiauh.components.moonraker import (
|
from components.moonraker import (
|
||||||
EXIT_MOONRAKER_SETUP,
|
EXIT_MOONRAKER_SETUP,
|
||||||
DEFAULT_MOONRAKER_REPO_URL,
|
DEFAULT_MOONRAKER_REPO_URL,
|
||||||
MOONRAKER_DIR,
|
MOONRAKER_DIR,
|
||||||
@@ -30,22 +30,22 @@ from kiauh.components.moonraker import (
|
|||||||
POLKIT_USR_FILE,
|
POLKIT_USR_FILE,
|
||||||
POLKIT_SCRIPT,
|
POLKIT_SCRIPT,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.components.moonraker.moonraker_dialogs import print_moonraker_overview
|
from components.moonraker.moonraker_dialogs import print_moonraker_overview
|
||||||
from kiauh.components.moonraker.moonraker_utils import (
|
from components.moonraker.moonraker_utils import (
|
||||||
create_example_moonraker_conf,
|
create_example_moonraker_conf,
|
||||||
backup_moonraker_dir,
|
backup_moonraker_dir,
|
||||||
)
|
)
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
from core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.filesystem_utils import check_file_exist
|
from utils.filesystem_utils import check_file_exist
|
||||||
from kiauh.utils.input_utils import (
|
from utils.input_utils import (
|
||||||
get_confirm,
|
get_confirm,
|
||||||
get_selection_input,
|
get_selection_input,
|
||||||
)
|
)
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import (
|
from utils.system_utils import (
|
||||||
parse_packages_from_file,
|
parse_packages_from_file,
|
||||||
create_python_venv,
|
create_python_venv,
|
||||||
install_python_requirements,
|
install_python_requirements,
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
import shutil
|
import shutil
|
||||||
from typing import Dict, Literal, List, Union
|
from typing import Dict, Literal, List, Union
|
||||||
|
|
||||||
from kiauh.components.mainsail import MAINSAIL_DIR
|
from components.mainsail import MAINSAIL_DIR
|
||||||
from kiauh.components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
from components.mainsail.mainsail_utils import enable_mainsail_remotemode
|
||||||
from kiauh.components.moonraker import (
|
from components.moonraker import (
|
||||||
DEFAULT_MOONRAKER_PORT,
|
DEFAULT_MOONRAKER_PORT,
|
||||||
MODULE_PATH,
|
MODULE_PATH,
|
||||||
MOONRAKER_DIR,
|
MOONRAKER_DIR,
|
||||||
@@ -22,14 +22,14 @@ from kiauh.components.moonraker import (
|
|||||||
MOONRAKER_BACKUP_DIR,
|
MOONRAKER_BACKUP_DIR,
|
||||||
MOONRAKER_DB_BACKUP_DIR,
|
MOONRAKER_DB_BACKUP_DIR,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker import Moonraker
|
from components.moonraker.moonraker import Moonraker
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
from core.backup_manager.backup_manager import BackupManager
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.core.repo_manager.repo_manager import RepoManager
|
from core.repo_manager.repo_manager import RepoManager
|
||||||
from kiauh.utils.common import get_install_status_common
|
from utils.common import get_install_status_common
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import (
|
from utils.system_utils import (
|
||||||
get_ipv4_addr,
|
get_ipv4_addr,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import shutil
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
from core.backup_manager import BACKUP_ROOT_DIR
|
||||||
from kiauh.utils.common import get_current_date
|
from utils.common import get_current_date
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import configparser
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from abc import abstractmethod, ABC
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Type, TypeVar
|
from typing import List, Type, TypeVar
|
||||||
|
|
||||||
from kiauh.utils.constants import SYSTEMD, CURRENT_USER
|
from utils.constants import SYSTEMD, CURRENT_USER
|
||||||
|
|
||||||
B = TypeVar(name="B", bound="BaseInstance", covariant=True)
|
B = TypeVar(name="B", bound="BaseInstance", covariant=True)
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional, Union, TypeVar
|
from typing import List, Optional, Union, TypeVar
|
||||||
|
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.utils.constants import SYSTEMD
|
from utils.constants import SYSTEMD
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
I = TypeVar(name="I", bound=BaseInstance, covariant=True)
|
I = TypeVar(name="I", bound=BaseInstance, covariant=True)
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from core.menus import BACK_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import COLOR_YELLOW, RESET_FORMAT
|
from utils.constants import COLOR_YELLOW, RESET_FORMAT
|
||||||
|
|
||||||
|
|
||||||
class AdvancedMenu(BaseMenu):
|
class AdvancedMenu(BaseMenu):
|
||||||
|
|||||||
@@ -11,16 +11,16 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper_utils import backup_klipper_dir
|
from components.klipper.klipper_utils import backup_klipper_dir
|
||||||
from kiauh.components.mainsail.mainsail_utils import backup_mainsail_data
|
from components.mainsail.mainsail_utils import backup_mainsail_data
|
||||||
from kiauh.components.moonraker.moonraker_utils import (
|
from components.moonraker.moonraker_utils import (
|
||||||
backup_moonraker_dir,
|
backup_moonraker_dir,
|
||||||
backup_moonraker_db_dir,
|
backup_moonraker_db_dir,
|
||||||
)
|
)
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from core.menus import BACK_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.common import backup_printer_config_dir
|
from utils.common import backup_printer_config_dir
|
||||||
from kiauh.utils.constants import COLOR_CYAN, RESET_FORMAT, COLOR_YELLOW
|
from utils.constants import COLOR_CYAN, RESET_FORMAT, COLOR_YELLOW
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
|
|||||||
@@ -15,15 +15,15 @@ import textwrap
|
|||||||
from abc import abstractmethod, ABC
|
from abc import abstractmethod, ABC
|
||||||
from typing import Dict, Any, Literal, Union, Callable
|
from typing import Dict, Any, Literal, Union, Callable
|
||||||
|
|
||||||
from kiauh.core.menus import QUIT_FOOTER, BACK_FOOTER, BACK_HELP_FOOTER
|
from core.menus import QUIT_FOOTER, BACK_FOOTER, BACK_HELP_FOOTER
|
||||||
from kiauh.utils.constants import (
|
from utils.constants import (
|
||||||
COLOR_GREEN,
|
COLOR_GREEN,
|
||||||
COLOR_YELLOW,
|
COLOR_YELLOW,
|
||||||
COLOR_RED,
|
COLOR_RED,
|
||||||
COLOR_CYAN,
|
COLOR_CYAN,
|
||||||
RESET_FORMAT,
|
RESET_FORMAT,
|
||||||
)
|
)
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def clear():
|
def clear():
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ import textwrap
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Dict
|
from typing import List, Dict
|
||||||
|
|
||||||
from kiauh.core.base_extension import BaseExtension
|
from core.base_extension import BaseExtension
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from core.menus import BACK_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import RESET_FORMAT, COLOR_CYAN, COLOR_YELLOW
|
from utils.constants import RESET_FORMAT, COLOR_CYAN, COLOR_YELLOW
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
|
|||||||
@@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.klipper import klipper_setup
|
from components.fluidd import fluidd_setup
|
||||||
from kiauh.components.mainsail import mainsail_setup
|
from components.klipper import klipper_setup
|
||||||
from kiauh.components.moonraker import moonraker_setup
|
from components.mainsail import mainsail_setup
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from components.moonraker import moonraker_setup
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus import BACK_FOOTER
|
||||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT
|
from core.menus.base_menu import BaseMenu
|
||||||
|
from utils.constants import COLOR_GREEN, RESET_FORMAT
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
@@ -74,7 +75,7 @@ class InstallMenu(BaseMenu):
|
|||||||
mainsail_setup.install_mainsail()
|
mainsail_setup.install_mainsail()
|
||||||
|
|
||||||
def install_fluidd(self, **kwargs):
|
def install_fluidd(self, **kwargs):
|
||||||
print("install_fluidd")
|
fluidd_setup.install_fluidd()
|
||||||
|
|
||||||
def install_klipperscreen(self, **kwargs):
|
def install_klipperscreen(self, **kwargs):
|
||||||
print("install_klipperscreen")
|
print("install_klipperscreen")
|
||||||
|
|||||||
@@ -11,20 +11,21 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper_utils import get_klipper_status
|
from components.fluidd.fluidd_utils import get_fluidd_status
|
||||||
from kiauh.components.log_uploads.menus.log_upload_menu import LogUploadMenu
|
from components.klipper.klipper_utils import get_klipper_status
|
||||||
from kiauh.components.mainsail.mainsail_utils import get_mainsail_status
|
from components.log_uploads.menus.log_upload_menu import LogUploadMenu
|
||||||
from kiauh.components.moonraker.moonraker_utils import get_moonraker_status
|
from components.mainsail.mainsail_utils import get_mainsail_status
|
||||||
from kiauh.core.menus import QUIT_FOOTER
|
from components.moonraker.moonraker_utils import get_moonraker_status
|
||||||
from kiauh.core.menus.advanced_menu import AdvancedMenu
|
from core.menus import QUIT_FOOTER
|
||||||
from kiauh.core.menus.backup_menu import BackupMenu
|
from core.menus.advanced_menu import AdvancedMenu
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.backup_menu import BackupMenu
|
||||||
from kiauh.core.menus.extensions_menu import ExtensionsMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.core.menus.install_menu import InstallMenu
|
from core.menus.extensions_menu import ExtensionsMenu
|
||||||
from kiauh.core.menus.remove_menu import RemoveMenu
|
from core.menus.install_menu import InstallMenu
|
||||||
from kiauh.core.menus.settings_menu import SettingsMenu
|
from core.menus.remove_menu import RemoveMenu
|
||||||
from kiauh.core.menus.update_menu import UpdateMenu
|
from core.menus.settings_menu import SettingsMenu
|
||||||
from kiauh.utils.constants import (
|
from core.menus.update_menu import UpdateMenu
|
||||||
|
from utils.constants import (
|
||||||
COLOR_MAGENTA,
|
COLOR_MAGENTA,
|
||||||
COLOR_CYAN,
|
COLOR_CYAN,
|
||||||
RESET_FORMAT,
|
RESET_FORMAT,
|
||||||
@@ -87,6 +88,8 @@ class MainMenu(BaseMenu):
|
|||||||
self.mr_repo = f"{COLOR_CYAN}{moonraker_status.get('repo')}{RESET_FORMAT}"
|
self.mr_repo = f"{COLOR_CYAN}{moonraker_status.get('repo')}{RESET_FORMAT}"
|
||||||
# mainsail
|
# mainsail
|
||||||
self.ms_status = get_mainsail_status()
|
self.ms_status = get_mainsail_status()
|
||||||
|
# fluidd
|
||||||
|
self.fl_status = get_fluidd_status()
|
||||||
|
|
||||||
def format_status_by_code(self, code: int, status: str, count: str) -> str:
|
def format_status_by_code(self, code: int, status: str, count: str) -> str:
|
||||||
if code == 1:
|
if code == 1:
|
||||||
|
|||||||
@@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.klipper.menus.klipper_remove_menu import KlipperRemoveMenu
|
from components.fluidd.menus.fluidd_remove_menu import FluiddRemoveMenu
|
||||||
from kiauh.components.mainsail.menus.mainsail_remove_menu import MainsailRemoveMenu
|
from components.klipper.menus.klipper_remove_menu import KlipperRemoveMenu
|
||||||
from kiauh.components.moonraker.menus.moonraker_remove_menu import MoonrakerRemoveMenu
|
from components.mainsail.menus.mainsail_remove_menu import MainsailRemoveMenu
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from components.moonraker.menus.moonraker_remove_menu import MoonrakerRemoveMenu
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus import BACK_FOOTER
|
||||||
from kiauh.utils.constants import COLOR_RED, RESET_FORMAT
|
from core.menus.base_menu import BaseMenu
|
||||||
|
from utils.constants import COLOR_RED, RESET_FORMAT
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
@@ -29,16 +30,16 @@ class RemoveMenu(BaseMenu):
|
|||||||
"1": KlipperRemoveMenu,
|
"1": KlipperRemoveMenu,
|
||||||
"2": MoonrakerRemoveMenu,
|
"2": MoonrakerRemoveMenu,
|
||||||
"3": MainsailRemoveMenu,
|
"3": MainsailRemoveMenu,
|
||||||
"5": self.remove_fluidd,
|
"4": FluiddRemoveMenu,
|
||||||
"6": self.remove_klipperscreen,
|
"5": None,
|
||||||
"7": self.remove_crowsnest,
|
"6": None,
|
||||||
"8": self.remove_mjpgstreamer,
|
"7": None,
|
||||||
"9": self.remove_pretty_gcode,
|
"8": None,
|
||||||
"10": self.remove_telegram_bot,
|
"9": None,
|
||||||
"11": self.remove_obico,
|
"10": None,
|
||||||
"12": self.remove_octoeverywhere,
|
"11": None,
|
||||||
"13": self.remove_mobileraker,
|
"12": None,
|
||||||
"14": self.remove_nginx,
|
"13": None,
|
||||||
},
|
},
|
||||||
footer_type=BACK_FOOTER,
|
footer_type=BACK_FOOTER,
|
||||||
)
|
)
|
||||||
@@ -69,36 +70,3 @@ class RemoveMenu(BaseMenu):
|
|||||||
"""
|
"""
|
||||||
)[1:]
|
)[1:]
|
||||||
print(menu, end="")
|
print(menu, end="")
|
||||||
|
|
||||||
def remove_fluidd(self, **kwargs):
|
|
||||||
print("remove_fluidd")
|
|
||||||
|
|
||||||
def remove_fluidd_config(self, **kwargs):
|
|
||||||
print("remove_fluidd_config")
|
|
||||||
|
|
||||||
def remove_klipperscreen(self, **kwargs):
|
|
||||||
print("remove_klipperscreen")
|
|
||||||
|
|
||||||
def remove_crowsnest(self, **kwargs):
|
|
||||||
print("remove_crowsnest")
|
|
||||||
|
|
||||||
def remove_mjpgstreamer(self, **kwargs):
|
|
||||||
print("remove_mjpgstreamer")
|
|
||||||
|
|
||||||
def remove_pretty_gcode(self, **kwargs):
|
|
||||||
print("remove_pretty_gcode")
|
|
||||||
|
|
||||||
def remove_telegram_bot(self, **kwargs):
|
|
||||||
print("remove_telegram_bot")
|
|
||||||
|
|
||||||
def remove_obico(self, **kwargs):
|
|
||||||
print("remove_obico")
|
|
||||||
|
|
||||||
def remove_octoeverywhere(self, **kwargs):
|
|
||||||
print("remove_octoeverywhere")
|
|
||||||
|
|
||||||
def remove_mobileraker(self, **kwargs):
|
|
||||||
print("remove_mobileraker")
|
|
||||||
|
|
||||||
def remove_nginx(self, **kwargs):
|
|
||||||
print("remove_nginx")
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
|||||||
@@ -11,20 +11,31 @@
|
|||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper_setup import update_klipper
|
from components.fluidd.fluidd_setup import update_fluidd
|
||||||
from kiauh.components.klipper.klipper_utils import (
|
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,
|
get_klipper_status,
|
||||||
)
|
)
|
||||||
from kiauh.components.mainsail.mainsail_setup import update_mainsail
|
from components.mainsail.mainsail_setup import update_mainsail
|
||||||
from kiauh.components.mainsail.mainsail_utils import (
|
from components.mainsail.mainsail_utils import (
|
||||||
get_mainsail_local_version,
|
get_mainsail_local_version,
|
||||||
get_mainsail_remote_version,
|
get_mainsail_remote_version,
|
||||||
)
|
)
|
||||||
from kiauh.components.moonraker.moonraker_setup import update_moonraker
|
from components.moonraker.moonraker_setup import update_moonraker
|
||||||
from kiauh.components.moonraker.moonraker_utils import get_moonraker_status
|
from components.moonraker.moonraker_utils import get_moonraker_status
|
||||||
from kiauh.core.menus import BACK_FOOTER
|
from core.menus import BACK_FOOTER
|
||||||
from kiauh.core.menus.base_menu import BaseMenu
|
from core.menus.base_menu import BaseMenu
|
||||||
from kiauh.utils.constants import COLOR_GREEN, RESET_FORMAT, COLOR_YELLOW, COLOR_WHITE
|
from utils.constants import (
|
||||||
|
COLOR_GREEN,
|
||||||
|
RESET_FORMAT,
|
||||||
|
COLOR_YELLOW,
|
||||||
|
COLOR_WHITE,
|
||||||
|
COLOR_RED,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
@@ -56,6 +67,8 @@ class UpdateMenu(BaseMenu):
|
|||||||
self.mr_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
self.mr_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||||
self.ms_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
self.ms_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||||
self.ms_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
self.ms_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||||
|
self.fl_local = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||||
|
self.fl_remote = f"{COLOR_WHITE}{RESET_FORMAT}"
|
||||||
|
|
||||||
def print_menu(self):
|
def print_menu(self):
|
||||||
self.fetch_update_status()
|
self.fetch_update_status()
|
||||||
@@ -76,7 +89,7 @@ class UpdateMenu(BaseMenu):
|
|||||||
| | | |
|
| | | |
|
||||||
| Klipper Webinterface: |---------------|---------------|
|
| Klipper Webinterface: |---------------|---------------|
|
||||||
| 3) Mainsail | {self.ms_local:<22} | {self.ms_remote:<22} |
|
| 3) Mainsail | {self.ms_local:<22} | {self.ms_remote:<22} |
|
||||||
| 4) Fluidd | | |
|
| 4) Fluidd | {self.fl_local:<22} | {self.fl_remote:<22} |
|
||||||
| | | |
|
| | | |
|
||||||
| Touchscreen GUI: |---------------|---------------|
|
| Touchscreen GUI: |---------------|---------------|
|
||||||
| 5) KlipperScreen | | |
|
| 5) KlipperScreen | | |
|
||||||
@@ -107,7 +120,7 @@ class UpdateMenu(BaseMenu):
|
|||||||
update_mainsail()
|
update_mainsail()
|
||||||
|
|
||||||
def update_fluidd(self, **kwargs):
|
def update_fluidd(self, **kwargs):
|
||||||
print("update_fluidd")
|
update_fluidd()
|
||||||
|
|
||||||
def update_klipperscreen(self, **kwargs):
|
def update_klipperscreen(self, **kwargs):
|
||||||
print("update_klipperscreen")
|
print("update_klipperscreen")
|
||||||
@@ -159,4 +172,12 @@ class UpdateMenu(BaseMenu):
|
|||||||
self.ms_local = f"{COLOR_GREEN}{self.ms_local}{RESET_FORMAT}"
|
self.ms_local = f"{COLOR_GREEN}{self.ms_local}{RESET_FORMAT}"
|
||||||
else:
|
else:
|
||||||
self.ms_local = f"{COLOR_YELLOW}{self.ms_local}{RESET_FORMAT}"
|
self.ms_local = f"{COLOR_YELLOW}{self.ms_local}{RESET_FORMAT}"
|
||||||
self.ms_remote = f"{COLOR_GREEN}{self.ms_remote}{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()
|
||||||
|
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}"
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiauh.utils.input_utils import get_confirm
|
from utils.input_utils import get_confirm
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
|||||||
@@ -13,21 +13,21 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
from core.backup_manager.backup_manager import BackupManager
|
||||||
from kiauh.core.base_extension import BaseExtension
|
from core.base_extension import BaseExtension
|
||||||
from kiauh.core.config_manager.config_manager import ConfigManager
|
from core.config_manager.config_manager import ConfigManager
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.extensions.gcode_shell_cmd import (
|
from extensions.gcode_shell_cmd import (
|
||||||
EXTENSION_TARGET_PATH,
|
EXTENSION_TARGET_PATH,
|
||||||
EXTENSION_SRC,
|
EXTENSION_SRC,
|
||||||
KLIPPER_DIR,
|
KLIPPER_DIR,
|
||||||
EXAMPLE_CFG_SRC,
|
EXAMPLE_CFG_SRC,
|
||||||
KLIPPER_EXTRAS,
|
KLIPPER_EXTRAS,
|
||||||
)
|
)
|
||||||
from kiauh.utils.filesystem_utils import check_file_exist
|
from utils.filesystem_utils import check_file_exist
|
||||||
from kiauh.utils.input_utils import get_confirm
|
from utils.input_utils import get_confirm
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyMethodMayBeStatic
|
# noinspection PyMethodMayBeStatic
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
from kiauh.core.menus.main_menu import MainMenu
|
from core.menus.main_menu import MainMenu
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from kiauh.core.backup_manager import BACKUP_ROOT_DIR
|
from core.backup_manager import BACKUP_ROOT_DIR
|
||||||
|
|
||||||
MODULE_PATH = Path(__file__).resolve().parent
|
MODULE_PATH = Path(__file__).resolve().parent
|
||||||
INVALID_CHOICE = "Invalid choice. Please select a valid value."
|
INVALID_CHOICE = "Invalid choice. Please select a valid value."
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# /etc/nginx/sites-available/%NAME%
|
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen %PORT%;
|
listen %PORT%;
|
||||||
|
# uncomment the next line to activate IPv6
|
||||||
|
# listen [::]:%PORT%;
|
||||||
|
|
||||||
access_log /var/log/nginx/%NAME%-access.log;
|
access_log /var/log/nginx/%NAME%-access.log;
|
||||||
error_log /var/log/nginx/%NAME%-error.log;
|
error_log /var/log/nginx/%NAME%-error.log;
|
||||||
@@ -55,7 +55,6 @@ server {
|
|||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Scheme $scheme;
|
proxy_set_header X-Scheme $scheme;
|
||||||
proxy_read_timeout 600;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location /webcam/ {
|
location /webcam/ {
|
||||||
|
|||||||
@@ -13,20 +13,20 @@ from datetime import datetime
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, Literal, List, Type, Union
|
from typing import Dict, Literal, List, Type, Union
|
||||||
|
|
||||||
from kiauh.components.klipper.klipper import Klipper
|
from components.klipper.klipper import Klipper
|
||||||
from kiauh.core.instance_manager.base_instance import BaseInstance
|
from core.instance_manager.base_instance import BaseInstance
|
||||||
from kiauh.core.instance_manager.instance_manager import InstanceManager
|
from core.instance_manager.instance_manager import InstanceManager
|
||||||
from kiauh.utils import PRINTER_CFG_BACKUP_DIR
|
from utils import PRINTER_CFG_BACKUP_DIR
|
||||||
from kiauh.utils.constants import (
|
from utils.constants import (
|
||||||
COLOR_CYAN,
|
COLOR_CYAN,
|
||||||
RESET_FORMAT,
|
RESET_FORMAT,
|
||||||
COLOR_YELLOW,
|
COLOR_YELLOW,
|
||||||
COLOR_GREEN,
|
COLOR_GREEN,
|
||||||
COLOR_RED,
|
COLOR_RED,
|
||||||
)
|
)
|
||||||
from kiauh.utils.filesystem_utils import check_file_exist
|
from utils.filesystem_utils import check_file_exist
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from kiauh.utils.system_utils import check_package_install, install_system_packages
|
from utils.system_utils import check_package_install, install_system_packages
|
||||||
|
|
||||||
|
|
||||||
def get_current_date() -> Dict[Literal["date", "time"], str]:
|
def get_current_date() -> Dict[Literal["date", "time"], str]:
|
||||||
@@ -122,7 +122,7 @@ def get_install_status_webui(
|
|||||||
|
|
||||||
def backup_printer_config_dir():
|
def backup_printer_config_dir():
|
||||||
# local import to prevent circular import
|
# local import to prevent circular import
|
||||||
from kiauh.core.backup_manager.backup_manager import BackupManager
|
from core.backup_manager.backup_manager import BackupManager
|
||||||
|
|
||||||
im = InstanceManager(Klipper)
|
im = InstanceManager(Klipper)
|
||||||
instances: List[Klipper] = im.instances
|
instances: List[Klipper] = im.instances
|
||||||
|
|||||||
@@ -7,18 +7,21 @@
|
|||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
from kiauh.utils import (
|
from typing import List
|
||||||
|
|
||||||
|
from utils import (
|
||||||
NGINX_SITES_AVAILABLE,
|
NGINX_SITES_AVAILABLE,
|
||||||
MODULE_PATH,
|
MODULE_PATH,
|
||||||
NGINX_CONFD,
|
NGINX_CONFD,
|
||||||
|
NGINX_SITES_ENABLED,
|
||||||
)
|
)
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def check_file_exist(file_path: Path, sudo=False) -> bool:
|
def check_file_exist(file_path: Path, sudo=False) -> bool:
|
||||||
@@ -133,3 +136,36 @@ def create_nginx_cfg(name: str, port: int, root_dir: Path) -> None:
|
|||||||
log = f"Unable to create '{target}': {e.stderr.decode()}"
|
log = f"Unable to create '{target}': {e.stderr.decode()}"
|
||||||
Logger.print_error(log)
|
Logger.print_error(log)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def read_ports_from_nginx_configs() -> List[str]:
|
||||||
|
"""
|
||||||
|
Helper function to iterate over all NGINX configs and read all ports defined for listen
|
||||||
|
:return: A sorted list of listen ports
|
||||||
|
"""
|
||||||
|
if not NGINX_SITES_ENABLED.exists():
|
||||||
|
return []
|
||||||
|
|
||||||
|
port_list = []
|
||||||
|
for config in NGINX_SITES_ENABLED.iterdir():
|
||||||
|
with open(config, "r") as cfg:
|
||||||
|
lines = cfg.readlines()
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
line = line.replace("default_server", "")
|
||||||
|
line = re.sub(r"[;:\[\]]", "", line.strip())
|
||||||
|
if line.startswith("listen") and line.split()[-1] not in port_list:
|
||||||
|
port_list.append(line.split()[-1])
|
||||||
|
|
||||||
|
return sorted(port_list, key=lambda x: int(x))
|
||||||
|
|
||||||
|
|
||||||
|
def is_valid_port(port: str, ports_in_use: List[str]) -> bool:
|
||||||
|
return port.isdigit() and port not in ports_in_use
|
||||||
|
|
||||||
|
|
||||||
|
def get_next_free_port(ports_in_use: List[str]) -> str:
|
||||||
|
valid_ports = set(range(80, 7125))
|
||||||
|
used_ports = set(map(int, ports_in_use))
|
||||||
|
|
||||||
|
return str(min(valid_ports - used_ports))
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
|
|
||||||
from typing import Optional, List, Union
|
from typing import Optional, List, Union
|
||||||
|
|
||||||
from kiauh.utils import INVALID_CHOICE
|
from utils import INVALID_CHOICE
|
||||||
from kiauh.utils.constants import COLOR_CYAN, RESET_FORMAT
|
from utils.constants import COLOR_CYAN, RESET_FORMAT
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
|
|
||||||
|
|
||||||
def get_confirm(
|
def get_confirm(
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
|
||||||
from kiauh.utils.constants import (
|
from utils.constants import (
|
||||||
COLOR_WHITE,
|
COLOR_WHITE,
|
||||||
COLOR_GREEN,
|
COLOR_GREEN,
|
||||||
COLOR_YELLOW,
|
COLOR_YELLOW,
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ import venv
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Literal
|
from typing import List, Literal
|
||||||
|
|
||||||
from kiauh.utils.input_utils import get_confirm
|
from utils.input_utils import get_confirm
|
||||||
from kiauh.utils.logger import Logger
|
from utils.logger import Logger
|
||||||
from kiauh.utils.filesystem_utils import check_file_exist
|
from utils.filesystem_utils import check_file_exist
|
||||||
|
|
||||||
|
|
||||||
def kill(opt_err_msg: str = "") -> None:
|
def kill(opt_err_msg: str = "") -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user