Skip to content

Commit 811aa01

Browse files
committed
Handle contests without start time gracefully.
1 parent e016edf commit 811aa01

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

provision-contest/replay.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@
4141
logging.info(f'Loaded {len(submissions)} submissions.')
4242

4343
contest_data = requests.get(f'{api_url}/contests/{contest}').json()
44+
while not contest_data['start_time']:
45+
logging.info(f'Start time unknown - contest delayed.')
46+
time_diff = 30
47+
spinner = Halo(spinner='dots', text=f'Sleeping for ~{str(round(time_diff,2))}s while waiting for contest start to be set.')
48+
spinner.start()
49+
time.sleep(time_diff)
50+
spinner.stop()
51+
contest_data = requests.get(f'{api_url}/contests/{contest}').json()
52+
4453
contest_start = datetime.strptime(contest_data['start_time'], '%Y-%m-%dT%H:%M:%S%z').timestamp()
4554
contest_duration = (datetime.strptime(contest_data['duration'], '%H:%M:%S.000') - datetime(1900, 1, 1)).total_seconds()
4655

0 commit comments

Comments
 (0)