Argparse cleanup

This commit is contained in:
Brett Williams
2025-03-06 10:07:19 -06:00
parent a9ccafc25d
commit 0f487640bd

View File

@@ -140,10 +140,11 @@ def process_new_job(args, server_data):
print(f"Found {len(available_servers)} servers available to build") print(f"Found {len(available_servers)} servers available to build")
print(tabulate(available_servers, headers="keys", tablefmt="grid")) print(tabulate(available_servers, headers="keys", tablefmt="grid"))
project_path = args.build
tmp_dir = tempfile.gettempdir() tmp_dir = tempfile.gettempdir()
zip_file = os.path.join(tmp_dir, f"{os.path.basename(args.path)}.zip") zip_file = os.path.join(tmp_dir, f"{os.path.basename(project_path)}.zip")
zip_project(args.path, zip_file) zip_project(project_path, zip_file)
print(f"Zipped {args.path} to {zip_file}") print(f"Zipped {project_path} to {zip_file}")
# Start builds on all matching servers # Start builds on all matching servers
with concurrent.futures.ThreadPoolExecutor() as executor: with concurrent.futures.ThreadPoolExecutor() as executor:
@@ -248,17 +249,17 @@ def update_build_workers(server_data):
def main(): def main():
parser = argparse.ArgumentParser(description="Build agent manager for cross-py-builder") 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("--status", action="store_true", help="Get status of available servers")
parser.add_argument("-path", type=str, help="Path to the project") 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("-cpu", type=str, help="CPU architecture")
parser.add_argument("-os", type=str, help="Operating system") parser.add_argument("-os", type=str, help="Operating system")
parser.add_argument("-d", '--download', action="store_true", help="Download after build") 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("--delete-cache", action="store_true", help="Delete cache")
parser.add_argument("-update-all", action="store_true", help="Update build agent") 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", type=str, help="Hostname to restart")
parser.add_argument("-restart-all", action="store_true", help="Restart all agents") 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", type=str, help="Hostname to shutdown")
parser.add_argument("-shutdown-all", action="store_true", help="Restart all agents") parser.add_argument("--shutdown-all", action="store_true", help="Restart all agents")
args = parser.parse_args() args = parser.parse_args()
if args.status: if args.status:
@@ -278,7 +279,7 @@ def main():
shutdown_agent(server_ip) shutdown_agent(server_ip)
elif args.delete_cache: elif args.delete_cache:
delete_cache(get_all_servers_status()) delete_cache(get_all_servers_status())
elif args.path: elif args.build:
process_new_job(args, get_all_servers_status()) process_new_job(args, get_all_servers_status())
elif args.update_all: elif args.update_all:
update_build_workers(get_all_servers_status()) update_build_workers(get_all_servers_status())