holy fuking shit
This commit is contained in:
@@ -43,8 +43,10 @@ class PracticeClient:
|
||||
status = response.status
|
||||
body = json.load(response)
|
||||
# A retried action is recorded/consumed only once.
|
||||
self.events.append(dict(path=path, request=payload, response=body, retries=attempt))
|
||||
self.output.write_text(json.dumps(self.events,ensure_ascii=False,indent=2),encoding='utf-8')
|
||||
self.events.append(dict(path=path, request=payload, response=body,
|
||||
retries=attempt))
|
||||
self.output.write_text(
|
||||
json.dumps(self.events,ensure_ascii=False,indent=2),encoding='utf-8')
|
||||
if status != 200 or body.get('accepted') is not True:
|
||||
raise RuntimeError(f'动作未被接受: {status}, {body}')
|
||||
if path == '/enter':
|
||||
@@ -54,6 +56,7 @@ class PracticeClient:
|
||||
if attempt == 2:
|
||||
raise
|
||||
time.sleep(.25)
|
||||
raise URLError('网络重试次数已用尽')
|
||||
|
||||
def measure(self, p, channel):
|
||||
return self.action('/measure',position={'x':p[0],'y':p[1]},channel=channel)
|
||||
@@ -106,12 +109,15 @@ def main():
|
||||
if len(observations)>=3:
|
||||
break
|
||||
data={'name':'官方问题3演练观测','source':'official_practice','case_code':args.case_code,
|
||||
'channel':channel,'ground_truth':None,'measurements':[m.__dict__ for m in observations],
|
||||
'channel':channel,'ground_truth':None,
|
||||
'measurements':[m.__dict__ for m in observations],
|
||||
'repeated_station_response':repeat,'result':solve(observations),
|
||||
'scope':'仅采集问题一观测,不执行问题三全清除任务;没有调用clear'}
|
||||
path=args.output/f'{args.case_code}_observations.json'
|
||||
path.write_text(json.dumps(data,ensure_ascii=False,indent=2,allow_nan=False),encoding='utf-8')
|
||||
print(json.dumps({'observations':str(path),'count':len(observations),'result':data['result']},ensure_ascii=False,indent=2))
|
||||
path.write_text(json.dumps(data,ensure_ascii=False,indent=2,allow_nan=False),
|
||||
encoding='utf-8')
|
||||
print(json.dumps({'observations':str(path),'count':len(observations),
|
||||
'result':data['result']},ensure_ascii=False,indent=2))
|
||||
finally:
|
||||
if entered:
|
||||
client.action('/exit')
|
||||
|
||||
Reference in New Issue
Block a user