Skip to content

Add contest export script #3039

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions misc-tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/dj_make_chroot_docker
/dj_run_chroot
/dj_judgehost_cleanup
/dj_utils.py
/force-passwords
3 changes: 2 additions & 1 deletion misc-tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ include $(TOPDIR)/Makefile.global
TARGETS =
OBJECTS =

SUBST_DOMSERVER = fix_permissions configure-domjudge import-contest force-passwords
SUBST_DOMSERVER = fix_permissions configure-domjudge dj_utils.py \
import-contest export-contest force-passwords

SUBST_JUDGEHOST = dj_make_chroot dj_run_chroot dj_make_chroot_docker \
dj_judgehost_cleanup
Expand Down
28 changes: 13 additions & 15 deletions misc-tools/configure-domjudge.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,17 @@ under the GNU GPL. See README and COPYING for details.
'''

import json
import os.path
import os
import requests
import requests.utils
import shutil
import sys
from argparse import ArgumentParser
from typing import List, Set

sys.path.append('@domserver_libdir@')
import dj_utils

webappdir = '@domserver_webappdir@'

def usage():
print(f'Usage: {sys.argv[0]} [<domjudge-api-url>]')
exit(1)


def compare_configs(expected_config: Set, actual_config: Set, num_spaces=4, key_mismatch_in_diff=False) -> (List, Set, Set):
diffs = []
space_string = ' ' * num_spaces
Expand All @@ -57,12 +51,16 @@ def _keyify_list(l: List) -> Set:
return { elem['id']: elem for elem in l }


if len(sys.argv) == 1:
dj_utils.domjudge_webapp_folder_or_api_url = webappdir
elif len(sys.argv) == 2:
dj_utils.domjudge_webapp_folder_or_api_url = sys.argv[1]
else:
usage()
parser = ArgumentParser(description='Configure DOMjudge via the API.')
parser.add_argument('-d', '--dir', help="directory to read configuration from, defaults to current directory")
parser.add_argument('-u', '--url', help="DOMjudge API URL to use, if not specified use the CLI interface")
args = parser.parse_args()

if args.dir:
os.chdir(args.dir)

if args.url:
dj_utils.domjudge_api_url = args.url

user_data = dj_utils.do_api_request('user')
if 'admin' not in user_data['roles']:
Expand All @@ -88,7 +86,7 @@ if os.path.exists('config.json'):
print(f' - missing keys from new config = {missing_keys}')
if diffs or new_keys or missing_keys:
if dj_utils.confirm(' - Upload these configuration changes?', True):
actual_config = dj_utils.do_api_request('config', 'PUT', expected_config)
actual_config = dj_utils.do_api_request('config', 'PUT', jsonData=expected_config)
diffs, new_keys, missing_keys = compare_configs(
actual_config=actual_config,
expected_config=expected_config
Expand Down
189 changes: 0 additions & 189 deletions misc-tools/dj_utils.py

This file was deleted.

Loading
Loading