From e05a42630ee3d88cdcafb00ec6e632ceb81bdbad Mon Sep 17 00:00:00 2001 From: dw-0 Date: Thu, 2 May 2024 15:51:52 +0200 Subject: [PATCH] refactor: use utils to handle service masking Signed-off-by: Dominik Willner --- kiauh/components/klipper/klipper_utils.py | 7 ++----- kiauh/utils/system_utils.py | 14 -------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/kiauh/components/klipper/klipper_utils.py b/kiauh/components/klipper/klipper_utils.py index c6693f7..75a3df0 100644 --- a/kiauh/components/klipper/klipper_utils.py +++ b/kiauh/components/klipper/klipper_utils.py @@ -45,7 +45,7 @@ from utils.constants import CURRENT_USER from utils.git_utils import get_repo_name, get_remote_commit, get_local_commit from utils.input_utils import get_confirm, get_string_input, get_number_input from utils.logger import Logger -from utils.system_utils import mask_system_service +from utils.system_utils import control_systemd_service def get_klipper_status() -> ( @@ -258,10 +258,7 @@ def handle_disruptive_system_packages() -> None: for service in services if services else []: try: - log = f"{service} service detected! Masking {service} service ..." - Logger.print_status(log) - mask_system_service(service) - Logger.print_ok(f"{service} service masked!") + control_systemd_service(service, "mask") except subprocess.CalledProcessError: warn_msg = textwrap.dedent( f""" diff --git a/kiauh/utils/system_utils.py b/kiauh/utils/system_utils.py index 3ebdf0d..69c3a22 100644 --- a/kiauh/utils/system_utils.py +++ b/kiauh/utils/system_utils.py @@ -233,20 +233,6 @@ def install_system_packages(packages: List[str]) -> None: raise -def mask_system_service(service_name: str) -> None: - """ - Mask a system service to prevent it from starting | - :param service_name: name of the service to mask - :return: None - """ - try: - control_systemd_service(service_name, "mask") - except CalledProcessError as e: - log = f"Unable to mask system service {service_name}: {e.stderr.decode()}" - Logger.print_error(log) - raise - - # this feels hacky and not quite right, but for now it works # see: https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib def get_ipv4_addr() -> str: