From 0f487640bd56bd15f4312db73b9056401f247130 Mon Sep 17 00:00:00 2001 From: Brett Williams Date: Thu, 6 Mar 2025 10:07:19 -0600 Subject: [PATCH] Argparse cleanup --- agent_manager.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/agent_manager.py b/agent_manager.py index 52dcc98..8e7ea1c 100755 --- a/agent_manager.py +++ b/agent_manager.py @@ -140,10 +140,11 @@ def process_new_job(args, server_data): print(f"Found {len(available_servers)} servers available to build") print(tabulate(available_servers, headers="keys", tablefmt="grid")) + project_path = args.build tmp_dir = tempfile.gettempdir() - zip_file = os.path.join(tmp_dir, f"{os.path.basename(args.path)}.zip") - zip_project(args.path, zip_file) - print(f"Zipped {args.path} to {zip_file}") + zip_file = os.path.join(tmp_dir, f"{os.path.basename(project_path)}.zip") + zip_project(project_path, zip_file) + print(f"Zipped {project_path} to {zip_file}") # Start builds on all matching servers with concurrent.futures.ThreadPoolExecutor() as executor: @@ -248,17 +249,17 @@ def update_build_workers(server_data): def main(): parser = argparse.ArgumentParser(description="Build agent manager for cross-py-builder") - parser.add_argument("-status", action="store_true", help="Get status of available servers") - parser.add_argument("-path", type=str, help="Path to the project") + parser.add_argument("--status", action="store_true", help="Get status of available servers") + parser.add_argument("--build", type=str, help="Path to the project to build") parser.add_argument("-cpu", type=str, help="CPU architecture") parser.add_argument("-os", type=str, help="Operating system") parser.add_argument("-d", '--download', action="store_true", help="Download after build") - parser.add_argument("-delete-cache", action="store_true", help="Delete cache") - parser.add_argument("-update-all", action="store_true", help="Update build agent") - parser.add_argument("-restart", type=str, help="Hostname to restart") - parser.add_argument("-restart-all", action="store_true", help="Restart all agents") - parser.add_argument("-shutdown", type=str, help="Hostname to shutdown") - parser.add_argument("-shutdown-all", action="store_true", help="Restart all agents") + parser.add_argument("--delete-cache", action="store_true", help="Delete cache") + parser.add_argument("--update-all", action="store_true", help="Update build agent") + parser.add_argument("--restart", type=str, help="Hostname to restart") + parser.add_argument("--restart-all", action="store_true", help="Restart all agents") + parser.add_argument("--shutdown", type=str, help="Hostname to shutdown") + parser.add_argument("--shutdown-all", action="store_true", help="Restart all agents") args = parser.parse_args() if args.status: @@ -278,7 +279,7 @@ def main(): shutdown_agent(server_ip) elif args.delete_cache: delete_cache(get_all_servers_status()) - elif args.path: + elif args.build: process_new_job(args, get_all_servers_status()) elif args.update_all: update_build_workers(get_all_servers_status())