summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 00:43:13 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 00:43:13 +0100
commit88cdb867368e93ec59740fa1b5a1440d2f438d05 (patch)
tree7fe7823ec11bc5b4aa9c5b99e8a0fa770d8fba9f
parent003e89608d5fd0ee13dbbe6f61654aeebebede43 (diff)
test_task: check and display argparser help before loading the task
Before --help was weirldy broken, apparently due to some bytes/str issue in the Python 2→3 conversion. Parameters are printed anyway after loading a task without -q.
-rwxr-xr-xkpov_judge/test_task.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py
index a1f3608..ad8c963 100755
--- a/kpov_judge/test_task.py
+++ b/kpov_judge/test_task.py
@@ -114,15 +114,15 @@ def load_params(filename):
if __name__ == '__main__':
# get the parameters needed to get to the task, such as the URLs, the name of the task and optionally an ID from the student
# start with the the parameters needed for the dialog gui to work
- argparser = argparse.ArgumentParser(conflict_handler='resolve', add_help=False,
- description='Get task parameters')
+ argparser = argparse.ArgumentParser(conflict_handler='resolve',
+ description='Test a KPOV Judge task.')
argparser.add_argument('-h', '--help', action='store_true')
argparser.add_argument('-q', '--quiet', action='store_true',
help='disable prompts')
argparser.add_argument('-g', '--generate_params', action='store_true',
help='generate initial values for the task parameters')
argparser.add_argument('-pf', '--params_file', nargs='?', default=PARAMS_FILE,
- help='a local file containing saved param values')
+ help='a local file with saved param values')
basic_args, unknown_args = argparser.parse_known_args()
# get default parameters including language
@@ -133,6 +133,10 @@ if __name__ == '__main__':
basic_args, unknown_args = argparser.parse_known_args()
params['language'] = basic_args.language
+ if basic_args.help:
+ argparser.print_help()
+ exit(0)
+
# continue with the parameters needed to get the task
params = locate_task(params, argparser, quiet=basic_args.quiet)
# TODO: if the task name is missing or invalid, try to get a list of tasks
@@ -205,9 +209,6 @@ if __name__ == '__main__':
task_params[k] = args[k]
if not basic_args.quiet:
task_params = get_params(task_params, task_params_meta, language=params['language'])
- if basic_args.help:
- print(task_argparser.format_help())
- exit(0)
public_params = {}
for k in inspect.getargs(task.__code__)[0]: