mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 08:13:36 +05:00
Compare commits
2 Commits
51993e367d
...
d6317ad439
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6317ad439 | ||
|
|
e28869be1a |
@@ -8,38 +8,38 @@
|
||||
# ======================================================================= #
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from subprocess import run, CalledProcessError
|
||||
from typing import List, Dict, Literal, Union
|
||||
from subprocess import CalledProcessError, run
|
||||
from typing import Dict, List, Literal, Union
|
||||
|
||||
from components.klipper.klipper import Klipper
|
||||
from components.mobileraker import (
|
||||
MOBILERAKER_REPO,
|
||||
MOBILERAKER_BACKUP_DIR,
|
||||
MOBILERAKER_DIR,
|
||||
MOBILERAKER_ENV,
|
||||
MOBILERAKER_BACKUP_DIR,
|
||||
MOBILERAKER_REPO,
|
||||
)
|
||||
from components.moonraker.moonraker import Moonraker
|
||||
from core.backup_manager.backup_manager import BackupManager
|
||||
from core.instance_manager.instance_manager import InstanceManager
|
||||
from core.settings.kiauh_settings import KiauhSettings
|
||||
from utils.common import get_install_status, check_install_dependencies
|
||||
from utils.common import check_install_dependencies, get_install_status
|
||||
from utils.config_utils import add_config_section, remove_config_section
|
||||
from utils.constants import SYSTEMD
|
||||
from utils.fs_utils import remove_with_sudo
|
||||
from utils.git_utils import (
|
||||
git_clone_wrapper,
|
||||
git_pull_wrapper,
|
||||
get_repo_name,
|
||||
get_local_commit,
|
||||
get_remote_commit,
|
||||
get_repo_name,
|
||||
git_clone_wrapper,
|
||||
git_pull_wrapper,
|
||||
)
|
||||
from utils.input_utils import get_confirm
|
||||
from utils.logger import Logger, DialogType
|
||||
from utils.logger import DialogType, Logger
|
||||
from utils.sys_utils import (
|
||||
check_python_version,
|
||||
cmd_sysctl_manage,
|
||||
cmd_sysctl_service,
|
||||
install_python_requirements,
|
||||
cmd_sysctl_manage,
|
||||
)
|
||||
|
||||
|
||||
@@ -111,8 +111,6 @@ def patch_mobileraker_update_manager(instances: List[Moonraker]) -> None:
|
||||
|
||||
def update_mobileraker() -> None:
|
||||
try:
|
||||
cmd_sysctl_service("KlipperScreen", "stop")
|
||||
|
||||
if not MOBILERAKER_DIR.exists():
|
||||
Logger.print_info(
|
||||
"Mobileraker's companion does not seem to be installed! Skipping ..."
|
||||
|
||||
@@ -7,15 +7,14 @@
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
# ======================================================================= #
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from subprocess import DEVNULL, CalledProcessError, run
|
||||
from typing import List
|
||||
|
||||
from core.instance_manager.base_instance import BaseInstance
|
||||
from utils.constants import SYSTEMD
|
||||
from utils.logger import Logger
|
||||
|
||||
|
||||
MODULE_PATH = Path(__file__).resolve().parent
|
||||
|
||||
TELEGRAM_BOT_DIR = Path.home().joinpath("moonraker-telegram-bot")
|
||||
@@ -64,7 +63,7 @@ class MoonrakerTelegramBot(BaseInstance):
|
||||
)
|
||||
self.write_env_file(env_template_file_path, env_file_target)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
except CalledProcessError as e:
|
||||
Logger.print_error(
|
||||
f"Error creating service file {service_file_target}: {e}"
|
||||
)
|
||||
@@ -81,9 +80,9 @@ class MoonrakerTelegramBot(BaseInstance):
|
||||
|
||||
try:
|
||||
command = ["sudo", "rm", "-f", service_file_path]
|
||||
subprocess.run(command, check=True)
|
||||
run(command, check=True)
|
||||
Logger.print_ok(f"Service file deleted: {service_file_path}")
|
||||
except subprocess.CalledProcessError as e:
|
||||
except CalledProcessError as e:
|
||||
Logger.print_error(f"Error deleting service file: {e}")
|
||||
raise
|
||||
|
||||
@@ -97,10 +96,10 @@ class MoonrakerTelegramBot(BaseInstance):
|
||||
service_template_path, env_file_target
|
||||
)
|
||||
command = ["sudo", "tee", service_file_target]
|
||||
subprocess.run(
|
||||
run(
|
||||
command,
|
||||
input=service_content.encode(),
|
||||
stdout=subprocess.DEVNULL,
|
||||
stdout=DEVNULL,
|
||||
check=True,
|
||||
)
|
||||
Logger.print_ok(f"Service file created: {service_file_target}")
|
||||
|
||||
@@ -14,22 +14,22 @@ from components.moonraker.moonraker import Moonraker
|
||||
from core.instance_manager.instance_manager import InstanceManager
|
||||
from extensions.base_extension import BaseExtension
|
||||
from extensions.telegram_bot.moonraker_telegram_bot import (
|
||||
MoonrakerTelegramBot,
|
||||
TELEGRAM_BOT_REPO,
|
||||
TELEGRAM_BOT_DIR,
|
||||
TELEGRAM_BOT_ENV,
|
||||
TELEGRAM_BOT_REPO,
|
||||
MoonrakerTelegramBot,
|
||||
)
|
||||
from utils.common import check_install_dependencies
|
||||
from utils.config_utils import add_config_section, remove_config_section
|
||||
from utils.fs_utils import remove_file
|
||||
from utils.git_utils import git_clone_wrapper, git_pull_wrapper
|
||||
from utils.input_utils import get_confirm
|
||||
from utils.logger import Logger, DialogType
|
||||
from utils.logger import DialogType, Logger
|
||||
from utils.sys_utils import (
|
||||
parse_packages_from_file,
|
||||
cmd_sysctl_manage,
|
||||
create_python_venv,
|
||||
install_python_requirements,
|
||||
cmd_sysctl_manage,
|
||||
parse_packages_from_file,
|
||||
)
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ class TelegramBotExtension(BaseExtension):
|
||||
DialogType.WARNING,
|
||||
[
|
||||
"No Moonraker instances found!",
|
||||
"Moonraker Telegram Bot requires Moonraker to be installed. Please install Moonraker first!",
|
||||
"Moonraker Telegram Bot requires Moonraker to be installed. "
|
||||
"Please install Moonraker first!",
|
||||
],
|
||||
)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user