refactor: improve code formatting and readability in service and update scripts
This commit is contained in:
parent
ca43384fb5
commit
243eb1688d
@ -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")
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user