|
26 | 26 | parser.add_argument('-c', '--contest', help='''submit for contest with ID CONTEST.
|
27 | 27 | Mandatory when more than one contest is active.''')
|
28 | 28 | parser.add_argument('-s', '--submissionid', help='submission to start at.')
|
| 29 | +parser.add_argument('--insecure', help='do not verify SSL certificate', action='store_true') |
29 | 30 | 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')
|
30 | 31 | parser.add_argument('-i', '--internal_data_source', help='The API uses an internal API source.', action='store_true')
|
31 | 32 |
|
32 | 33 | args = parser.parse_args()
|
33 | 34 |
|
34 | 35 | api_url = args.api_url
|
| 36 | +verify = not args.insecure |
35 | 37 | if args.contest:
|
36 | 38 | contest = args.contest
|
37 | 39 | else:
|
38 |
| - contests = requests.get(f'{api_url}/contests').json() |
| 40 | + contests = requests.get(f'{api_url}/contests', verify=verify).json() |
39 | 41 | if len(contests) == 1:
|
40 | 42 | contest = contests[0]['id']
|
41 | 43 | else:
|
|
49 | 51 | submissions = json.load(open('submissions.json'))
|
50 | 52 | logging.info(f'Loaded {len(submissions)} submissions.')
|
51 | 53 |
|
52 |
| -contest_data = requests.get(f'{api_url}/contests/{contest}').json() |
| 54 | +contest_data = requests.get(f'{api_url}/contests/{contest}', verify=verify).json() |
53 | 55 | while not contest_data['start_time']:
|
54 | 56 | logging.info(f'Start time unknown - contest delayed.')
|
55 | 57 | time_diff = 30
|
56 | 58 | spinner = Halo(spinner='dots', text=f'Sleeping for ~{str(round(time_diff,2))}s while waiting for contest start to be set.')
|
57 | 59 | spinner.start()
|
58 | 60 | time.sleep(time_diff)
|
59 | 61 | 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() |
61 | 63 |
|
62 | 64 | contest_start = datetime.strptime(contest_data['start_time'], '%Y-%m-%dT%H:%M:%S%z').timestamp()
|
63 | 65 | contest_start_obj = datetime.strptime(contest_data['start_time'], '%Y-%m-%dT%H:%M:%S%z')
|
64 | 66 | contest_duration = (datetime.strptime(contest_data['duration'], '%H:%M:%S.000') - datetime(1900, 1, 1)).total_seconds()
|
65 | 67 |
|
66 | 68 | if not args.no_remap_teams:
|
67 | 69 | # 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() |
69 | 71 | team_ids = [team['id'] for team in team_data if not team['hidden']]
|
70 | 72 |
|
71 | 73 | if not team_ids:
|
|
172 | 174 | submissions_api_url,
|
173 | 175 | data = data,
|
174 | 176 | files = files,
|
| 177 | + verify = verify, |
175 | 178 | )
|
176 | 179 | if r.status_code == 200:
|
177 | 180 | sid = r.json()['id']
|
|
0 commit comments