diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-09-26 17:30:47 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2018-09-27 11:31:18 +0200 |
commit | ac07a3ddc685025ac15cf502d5fea78e1670871c (patch) | |
tree | 87582e490bfe2207c38ed01e3f2ef4aece82cacd /kpov_judge/web | |
parent | 03c9d6d8441e3293b058fed270866419781b734c (diff) |
Fix exec() for Python 3
Diffstat (limited to 'kpov_judge/web')
-rwxr-xr-x | kpov_judge/web/kpov_judge/kpov_judge.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py index 1605089..5d3e791 100755 --- a/kpov_judge/web/kpov_judge/kpov_judge.py +++ b/kpov_judge/web/kpov_judge/kpov_judge.py @@ -90,10 +90,10 @@ def results_post(class_id, task_id, results): params[param_name] = user_params[param_name] try: task_check_source = db.task_checkers.find_one({'class_id': class_id, 'task_id': task_id})['source'] - task_check_code = compile(task_check_source, 'checker.py', 'exec') - exec(task_check_code) + d = {} + exec(compile(task_check_source, 'checker.py', 'exec'), d) # raise Exception(str(params)) - res, hints = task_check(results, params) + res, hints = d['task_check'](results, params) except Exception as e: hints = ["Checker died: " + str(e)] res = 0 @@ -187,11 +187,12 @@ def get_params(class_id, task_id, student_id, db): try: gen_params_source = db.gen_params.find_one({'class_id': class_id, 'task_id': task_id})['source'] gen_params_code = compile(gen_params_source, 'generator.py', 'exec') - exec(gen_params_code) - params = gen_params(student_id, meta) + d = {} + exec(gen_params_code, d) + params = d['gen_params'](student_id, meta) db.task_params.update({'class_id': class_id, 'task_id': task_id, 'student_id': student_id}, {'$set': {'params': params}}, upsert=True) - params = gen_params(student_id, meta) + params = d['gen_params'](student_id, meta) # TODO this is repeated, is it necessary? for computer in db.computers_meta.find({'class_id': class_id, 'task_id': task_id}): try: name = computer.pop('name') |