|
|
@ -111,7 +111,6 @@ def get_state(min_round: int, args) -> dict: |
|
|
|
logger.warning(f"Request error: {e}") |
|
|
|
return None, TIME_BEFORE_RETRY |
|
|
|
if not res.ok: |
|
|
|
logger.error(f"Server error: {res.status_code} {res.reason}") |
|
|
|
log_server_error(res) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
@ -161,23 +160,20 @@ def send_turn(turn: dict, round: int, args) -> None: |
|
|
|
# print errors |
|
|
|
# because such errors are caused by the submitted turn, |
|
|
|
# retrying will not help, so return True |
|
|
|
response = res.json() |
|
|
|
if response["status"] == "ok": |
|
|
|
res_json = res.json() |
|
|
|
if res_json["status"] == "ok": |
|
|
|
logger.info("Turn accepted.") |
|
|
|
elif response["status"] == "too_late": |
|
|
|
elif res_json["status"] == "too_late": |
|
|
|
logger.error("Turn submitted too late.") |
|
|
|
elif response["status"] == "error": |
|
|
|
logger.error(f"Turn error: {response['description']}") |
|
|
|
elif response["status"] == "warning": |
|
|
|
member_warns = [ |
|
|
|
elif res_json["status"] == "error": |
|
|
|
logger.error(f"Turn error: {res_json['description']}") |
|
|
|
elif res_json["status"] == "warning": |
|
|
|
member_warns = "\n".join([ |
|
|
|
f" {member['id']}: {member['description']}" |
|
|
|
for member in response["members"] |
|
|
|
] |
|
|
|
for member in res_json["members"] |
|
|
|
]) |
|
|
|
logger.info("Turn accepted with warnings.") |
|
|
|
logger.warning( |
|
|
|
"Member warnings:\n" |
|
|
|
"\n".join(member_warns) |
|
|
|
) |
|
|
|
logger.warning(f"Member warnings:\n{member_warns}") |
|
|
|
return True |
|
|
|
|
|
|
|
while not send_turn_once(): |
|
|
@ -185,9 +181,10 @@ def send_turn(turn: dict, round: int, args) -> None: |
|
|
|
|
|
|
|
|
|
|
|
def log_server_error(res: requests.Response) -> None: |
|
|
|
res_json = res.json() |
|
|
|
logger.error( |
|
|
|
f"Server error: {res.status_code} {res.reason}\n" |
|
|
|
f"{res['description']}" |
|
|
|
f"Server error: {res.status_code} {res.reason}: " |
|
|
|
f"{res_json['description']}" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|