mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 08:43:36 +05:00
refactor(kiauh): reword print_info to print_status and implement new print_info method
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -38,7 +38,7 @@ class Klipper(BaseInstance):
|
||||
self.uds = f"{self.comms_dir}/klippy.sock"
|
||||
|
||||
def create(self) -> None:
|
||||
Logger.print_info("Creating new Klipper Instance ...")
|
||||
Logger.print_status("Creating new Klipper Instance ...")
|
||||
module_path = os.path.dirname(os.path.abspath(__file__))
|
||||
service_template_path = os.path.join(module_path, "res", "klipper.service")
|
||||
env_template_file_path = os.path.join(module_path, "res", "klipper.env")
|
||||
@@ -66,7 +66,7 @@ class Klipper(BaseInstance):
|
||||
service_file = self.get_service_file_name(extension=True)
|
||||
service_file_path = self.get_service_file_path()
|
||||
|
||||
Logger.print_info(f"Deleting Klipper Instance: {service_file}")
|
||||
Logger.print_status(f"Deleting Klipper Instance: {service_file}")
|
||||
|
||||
try:
|
||||
command = ["sudo", "rm", "-f", service_file_path]
|
||||
@@ -113,12 +113,12 @@ class Klipper(BaseInstance):
|
||||
|
||||
def _delete_klipper_remnants(self) -> None:
|
||||
try:
|
||||
Logger.print_info(f"Delete {self.klipper_dir} ...")
|
||||
Logger.print_status(f"Delete {self.klipper_dir} ...")
|
||||
shutil.rmtree(Path(self.klipper_dir))
|
||||
Logger.print_info(f"Delete {self.env_dir} ...")
|
||||
Logger.print_status(f"Delete {self.env_dir} ...")
|
||||
shutil.rmtree(Path(self.env_dir))
|
||||
except FileNotFoundError:
|
||||
Logger.print_info("Cannot delete Klipper directories. Not found.")
|
||||
Logger.print_status("Cannot delete Klipper directories. Not found.")
|
||||
except PermissionError as e:
|
||||
Logger.print_error(f"Error deleting Klipper directories: {e}")
|
||||
raise
|
||||
|
||||
@@ -67,7 +67,7 @@ def run_klipper_setup(install: bool) -> None:
|
||||
if install:
|
||||
add_additional = handle_existing_instances(instance_list)
|
||||
if is_klipper_installed and not add_additional:
|
||||
Logger.print_info(EXIT_KLIPPER_SETUP)
|
||||
Logger.print_status(EXIT_KLIPPER_SETUP)
|
||||
return
|
||||
|
||||
install_klipper(instance_manager, instance_list)
|
||||
@@ -97,12 +97,12 @@ def install_klipper(
|
||||
question = f"Number of{' additional' if len(instance_list) > 0 else ''} Klipper instances to set up"
|
||||
install_count = get_number_input(question, 1, default=1, allow_go_back=True)
|
||||
if install_count is None:
|
||||
Logger.print_info(EXIT_KLIPPER_SETUP)
|
||||
Logger.print_status(EXIT_KLIPPER_SETUP)
|
||||
return
|
||||
|
||||
instance_names = set_instance_suffix(instance_list, install_count)
|
||||
if instance_names is None:
|
||||
Logger.print_info(EXIT_KLIPPER_SETUP)
|
||||
Logger.print_status(EXIT_KLIPPER_SETUP)
|
||||
return
|
||||
|
||||
if len(instance_list) < 1:
|
||||
@@ -199,7 +199,7 @@ def remove_single_instance(
|
||||
question = f"Delete {KLIPPER_DIR} and {KLIPPER_ENV_DIR}?"
|
||||
del_remnants = get_confirm(question, allow_go_back=True)
|
||||
if del_remnants is None:
|
||||
Logger.print_info("Exiting Klipper Uninstaller ...")
|
||||
Logger.print_status("Exiting Klipper Uninstaller ...")
|
||||
return
|
||||
|
||||
try:
|
||||
@@ -229,10 +229,10 @@ def remove_multi_instance(
|
||||
question = f"Delete {KLIPPER_DIR} and {KLIPPER_ENV_DIR}?"
|
||||
del_remnants = get_confirm(question, allow_go_back=True)
|
||||
if del_remnants is None:
|
||||
Logger.print_info("Exiting Klipper Uninstaller ...")
|
||||
Logger.print_status("Exiting Klipper Uninstaller ...")
|
||||
return
|
||||
|
||||
Logger.print_info("Removing all Klipper instances ...")
|
||||
Logger.print_status("Removing all Klipper instances ...")
|
||||
for instance in instance_list:
|
||||
instance_manager.current_instance = instance
|
||||
instance_manager.stop_instance()
|
||||
@@ -241,7 +241,7 @@ def remove_multi_instance(
|
||||
else:
|
||||
instance = instance_list[int(selection)]
|
||||
log = f"Removing Klipper instance: {instance.get_service_file_name()}"
|
||||
Logger.print_info(log)
|
||||
Logger.print_status(log)
|
||||
instance_manager.current_instance = instance
|
||||
instance_manager.stop_instance()
|
||||
instance_manager.disable_instance()
|
||||
|
||||
@@ -128,7 +128,7 @@ def check_user_groups():
|
||||
|
||||
try:
|
||||
for group in missing_groups:
|
||||
Logger.print_info(f"Adding user '{CURRENT_USER}' to group {group} ...")
|
||||
Logger.print_status(f"Adding user '{CURRENT_USER}' to group {group} ...")
|
||||
command = ["sudo", "usermod", "-a", "-G", group, CURRENT_USER]
|
||||
subprocess.run(command, check=True)
|
||||
Logger.print_ok(f"Group {group} assigned to user '{CURRENT_USER}'.")
|
||||
@@ -162,7 +162,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_info(log)
|
||||
Logger.print_status(log)
|
||||
mask_system_service(service)
|
||||
Logger.print_ok(f"{service} service masked!")
|
||||
except subprocess.CalledProcessError:
|
||||
|
||||
Reference in New Issue
Block a user