planet-wars/client/run_all.py
2020-03-30 11:32:26 +02:00

16 lines
405 B
Python

import requests, json, subprocess, os
host = os.getenv("HOST") or "localhost:8000"
headers = {'content-type': 'application/json'}
r = requests.post(f"http://{host}/lobby", data=open('game_start.json').read(), headers=headers)
data = r.json()
processes = []
for player in data["players"]:
processes.append(
subprocess.Popen(["./run.sh", str(player)])
)
for p in processes:
p.wait()