|
|
@ -25,6 +25,7 @@ def get_state(min_round: int, args) -> Tuple[Optional[dict], float]: |
|
|
|
logger.warning(f"Server error: {r.status_code} {r.reason}") |
|
|
|
return None, TIME_BEFORE_RETRY |
|
|
|
|
|
|
|
state = r.json() |
|
|
|
# also retry if the server is not willing to give us the state yet |
|
|
|
if state["status"] == "waiting": |
|
|
|
logger.info("Server is busy.") |
|
|
@ -33,7 +34,6 @@ def get_state(min_round: int, args) -> Tuple[Optional[dict], float]: |
|
|
|
logger.info("Round didn't start yet.") |
|
|
|
return None, state["wait"] |
|
|
|
|
|
|
|
state = json.loads(r.json()) |
|
|
|
logger.info("Received new state.") |
|
|
|
return state, 0 |
|
|
|
|
|
|
@ -43,7 +43,7 @@ def send_turn(turn: dict, round: int, args) -> bool: |
|
|
|
|
|
|
|
try: |
|
|
|
r = requests.post( |
|
|
|
f"{args.server}/api/state", |
|
|
|
f"{args.server}/api/action", |
|
|
|
params={ |
|
|
|
"game": args.game, |
|
|
|
"token": args.token, |
|
|
@ -61,7 +61,7 @@ def send_turn(turn: dict, round: int, args) -> bool: |
|
|
|
# print errors |
|
|
|
# because such errors are caused by the submitted turn, |
|
|
|
# retrying will not help, so return True |
|
|
|
response = json.loads(r.json()) |
|
|
|
response = r.json() |
|
|
|
if response["status"] == "ok": |
|
|
|
logger.info("Turn accepted.") |
|
|
|
elif response["status"] == "too_late": |
|
|
@ -73,6 +73,6 @@ def send_turn(turn: dict, round: int, args) -> bool: |
|
|
|
f" {member}: {error}" |
|
|
|
for member, error in response["errors"].items() |
|
|
|
] |
|
|
|
logger.error(f"Member errors:\n{'\n'.join(member_errors)}") |
|
|
|
logger.error("Member errors:\n" + "\n".join(member_errors)) |
|
|
|
|
|
|
|
return True |
|
|
|