planet-wars/client/run_all.py
2020-04-01 20:49:50 +02:00

23 lines
559 B
Python

import requests, json, subprocess, os
host = os.getenv("HOST") or "localhost:8000"
headers = {'content-type': 'application/json'}
try:
r = requests.post(f"https://{host}/lobby", data=open('game_start.json').read(), headers=headers)
data = r.json()
except Exception:
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()