planet-wars/client/run_all.py

23 lines
559 B
Python
Raw Permalink Normal View History

2020-03-30 11:32:26 +02:00
import requests, json, subprocess, os
host = os.getenv("HOST") or "localhost:8000"
2020-04-01 20:49:50 +02:00
2020-03-30 11:32:26 +02:00
headers = {'content-type': 'application/json'}
2020-04-01 20:49:50 +02:00
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()
2020-03-30 11:32:26 +02:00
processes = []
for player in data["players"]:
processes.append(
subprocess.Popen(["./run.sh", str(player)])
)
for p in processes:
p.wait()