mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 00:03:42 +05:00
refactor: use utils to handle service masking
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -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"""
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user