Skip to content

Commit 42f6e32

Browse files
Add option to not verify SSL certifcate for replaying.
1 parent ac63cc7 commit 42f6e32

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

provision-contest/replay.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@
2626
parser.add_argument('-c', '--contest', help='''submit for contest with ID CONTEST.
2727
Mandatory when more than one contest is active.''')
2828
parser.add_argument('-s', '--submissionid', help='submission to start at.')
29+
parser.add_argument('--insecure', help='do not verify SSL certificate', action='store_true')
2930
parser.add_argument('-r', '--no_remap_teams', help='do not remap team ID\'s to team ID\'s of contest from API.', action='store_true')
3031
parser.add_argument('-i', '--internal_data_source', help='The API uses an internal API source.', action='store_true')
3132

3233
args = parser.parse_args()
3334

3435
api_url = args.api_url
36+
verify = not args.insecure
3537
if args.contest:
3638
contest = args.contest
3739
else:
38-
contests = requests.get(f'{api_url}/contests').json()
40+
contests = requests.get(f'{api_url}/contests', verify=verify).json()
3941
if len(contests) == 1:
4042
contest = contests[0]['id']
4143
else:
@@ -49,23 +51,23 @@
4951
submissions = json.load(open('submissions.json'))
5052
logging.info(f'Loaded {len(submissions)} submissions.')
5153

52-
contest_data = requests.get(f'{api_url}/contests/{contest}').json()
54+
contest_data = requests.get(f'{api_url}/contests/{contest}', verify=verify).json()
5355
while not contest_data['start_time']:
5456
logging.info(f'Start time unknown - contest delayed.')
5557
time_diff = 30
5658
spinner = Halo(spinner='dots', text=f'Sleeping for ~{str(round(time_diff,2))}s while waiting for contest start to be set.')
5759
spinner.start()
5860
time.sleep(time_diff)
5961
spinner.stop()
60-
contest_data = requests.get(f'{api_url}/contests/{contest}').json()
62+
contest_data = requests.get(f'{api_url}/contests/{contest}', verify=verify).json()
6163

6264
contest_start = datetime.strptime(contest_data['start_time'], '%Y-%m-%dT%H:%M:%S%z').timestamp()
6365
contest_start_obj = datetime.strptime(contest_data['start_time'], '%Y-%m-%dT%H:%M:%S%z')
6466
contest_duration = (datetime.strptime(contest_data['duration'], '%H:%M:%S.000') - datetime(1900, 1, 1)).total_seconds()
6567

6668
if not args.no_remap_teams:
6769
# Get the teams from the contest
68-
team_data = requests.get(f'{api_url}/contests/{contest}/teams').json()
70+
team_data = requests.get(f'{api_url}/contests/{contest}/teams', verify=verify).json()
6971
team_ids = [team['id'] for team in team_data if not team['hidden']]
7072

7173
if not team_ids:
@@ -172,6 +174,7 @@
172174
submissions_api_url,
173175
data = data,
174176
files = files,
177+
verify = verify,
175178
)
176179
if r.status_code == 200:
177180
sid = r.json()['id']

0 commit comments

Comments
 (0)