From 243eb1688d64aaaed5ac7684c057e351c38d7870 Mon Sep 17 00:00:00 2001 From: Menno van Leeuwen Date: Mon, 24 Mar 2025 18:28:06 +0100 Subject: [PATCH] refactor: improve code formatting and readability in service and update scripts --- bin/actions/service.py | 35 ++++++++++++++++++++++++++--------- bin/actions/update.py | 4 +++- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/bin/actions/service.py b/bin/actions/service.py index 4bf21f7..0946019 100755 --- a/bin/actions/service.py +++ b/bin/actions/service.py @@ -101,14 +101,19 @@ def cmd_stop(args): # Filter out the protected services safe_services = [s for s in running_services if s not in PROTECTED_SERVICES] - + # Check if protected services were filtered out protected_running = [s for s in running_services if s in PROTECTED_SERVICES] if protected_running: - printfe("yellow", f"Note: {', '.join(protected_running)} will not be stopped as they are protected services") - + printfe( + "yellow", + f"Note: {', '.join(protected_running)} will not be stopped as they are protected services", + ) + if not safe_services: - printfe("yellow", "No services to stop (all running services are protected)") + printfe( + "yellow", "No services to stop (all running services are protected)" + ) return 0 printfe("blue", f"Stopping all running services: {', '.join(safe_services)}") @@ -132,8 +137,14 @@ def cmd_stop(args): else: # Check if trying to stop a protected service if args.service in PROTECTED_SERVICES: - printfe("red", f"Error: {args.service} is a protected service and cannot be stopped") - printfe("yellow", f"The {args.service} service is required for other services to work properly") + printfe( + "red", + f"Error: {args.service} is a protected service and cannot be stopped", + ) + printfe( + "yellow", + f"The {args.service} service is required for other services to work properly", + ) return 1 return run_docker_compose(["down"], service_name=args.service) @@ -287,7 +298,9 @@ def main(): start_group = start_parser.add_mutually_exclusive_group(required=True) start_group.add_argument("--all", action="store_true", help="Start all services") start_group.add_argument("service", nargs="?", help="Service to start") - start_group.add_argument("--service", dest="service", help="Service to start (deprecated)") + start_group.add_argument( + "--service", dest="service", help="Service to start (deprecated)" + ) # Stop command stop_parser = subparsers.add_parser("stop", help="Stop a Docker service") @@ -296,7 +309,9 @@ def main(): "--all", action="store_true", help="Stop all running services" ) stop_group.add_argument("service", nargs="?", help="Service to stop") - stop_group.add_argument("--service", dest="service", help="Service to stop (deprecated)") + stop_group.add_argument( + "--service", dest="service", help="Service to stop (deprecated)" + ) # Restart command restart_parser = subparsers.add_parser("restart", help="Restart a Docker service") @@ -312,7 +327,9 @@ def main(): "--all", action="store_true", help="Update all running services" ) update_group.add_argument("service", nargs="?", help="Service to update") - update_group.add_argument("--service", dest="service", help="Service to update (deprecated)") + update_group.add_argument( + "--service", dest="service", help="Service to update (deprecated)" + ) # PS command ps_parser = subparsers.add_parser("ps", help="Show Docker service status") diff --git a/bin/actions/update.py b/bin/actions/update.py index 67462b8..f29b96d 100755 --- a/bin/actions/update.py +++ b/bin/actions/update.py @@ -59,7 +59,9 @@ def check_git_repository(): # Fetch the latest changes status, output = run_command(["git", "fetch"], shell=False) if not status: - printfe("yellow", f"Warning: Failed to fetch changes from git repository: {output}") + printfe( + "yellow", f"Warning: Failed to fetch changes from git repository: {output}" + ) printfe("yellow", "Continuing update process without repository check...") os.chdir(current_dir) return True