Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve contest ID handling in submit client. #2943

Merged
merged 1 commit into from
Mar 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions submit/submit
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,21 @@ def get_epilog():
contests_part_one = None
contests_part_two = None

if not contests or len(contests) <= 1:
if contest_id:
contests_part_one = '''For CONTEST use the ID or short name as shown in the top-right contest
drop-down box in the web interface.'''
if contests and len(contests) == 1:
contests_part_two = f"Currently this defaults to the only active contest '{contests[0]['shortname']}'"
drop-down box in the web interface.'''
contests_part_two = f"Currently defaults to '{contest_id}', pass '-c <contest_id>' to override."
else:
contests_part_one = 'For CONTEST use one of the following:'
max_length = max([len(c['shortname']) for c in contests])
for contest in contests:
contests_part_one += f"\n {contest['shortname']:<{max_length}} - {contest['name']}"
if not contests or len(contests) <= 1:
contests_part_one = '''For CONTEST use the ID or short name as shown in the top-right contest
drop-down box in the web interface.'''
if contests and len(contests) == 1:
contests_part_two = f"Currently this defaults to the only active contest '{contests[0]['shortname']}'"
else:
contests_part_one = 'For CONTEST use one of the following:'
max_length = max([len(c['shortname']) for c in contests])
for contest in contests:
contests_part_one += f"\n {contest['shortname']:<{max_length}} - {contest['name']}"

if not problems:
problem_part = 'For PROBLEM use the label as on the scoreboard.'
Expand Down Expand Up @@ -459,6 +464,8 @@ if args.url:
baseurl = args.url
elif 'SUBMITBASEURL' in os.environ:
baseurl = os.environ['SUBMITBASEURL']
logging.warning(f"Using '{baseurl}' as defined in the 'SUBMITBASEURL' environment variable. "
+ "Pass '-u <url>' to override.")
# Make sure that baseurl terminates with a '/' for later concatenation.
if baseurl and baseurl[-1:] != '/':
baseurl += '/'
Expand All @@ -467,6 +474,8 @@ if args.contest:
contest_id = args.contest
elif 'SUBMITCONTEST' in os.environ:
contest_id = os.environ['SUBMITCONTEST']
logging.warning(f"Using '{contest_id}' as defined in the 'SUBMITCONTEST' environment variable. "
+ "Pass '-c <contest_id>' to override.")
else:
contest_id = ''

Expand Down
Loading