refactor: improve code formatting and readability in service and update scripts
Some checks failed
Ansible Lint Check / check-ansible (push) Failing after 17s
Nix Format Check / check-format (push) Successful in 58s
Python Lint Check / check-python (push) Failing after 14s

This commit is contained in:
Menno van Leeuwen 2025-03-24 18:28:06 +01:00
parent ca43384fb5
commit 243eb1688d
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
2 changed files with 29 additions and 10 deletions

View File

@ -105,10 +105,15 @@ def cmd_stop(args):
# 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")

View File

@ -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