summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkpov_judge/add_task.py2
-rwxr-xr-xkpov_judge/create_disk_images.py2
-rw-r--r--kpov_judge/instructions_extractor.py5
-rwxr-xr-xkpov_judge/test_prepare_disks.py2
-rwxr-xr-xkpov_judge/test_task.py2
-rwxr-xr-xkpov_judge/web/kpov_judge/kpov_judge.py4
6 files changed, 9 insertions, 8 deletions
diff --git a/kpov_judge/add_task.py b/kpov_judge/add_task.py
index 4fa250f..c995583 100755
--- a/kpov_judge/add_task.py
+++ b/kpov_judge/add_task.py
@@ -54,7 +54,7 @@ if __name__ == '__main__':
source = open(fname).read()
d = {}
# defines task, task_check, gen_params, prepare_disks, computers, params_meta
- exec(compile(source, fname, 'exec'), d)
+ exec(compile(source, fname, 'exec'), globals(), d)
public_meta = {}
for k, v in d['params_meta'].items():
diff --git a/kpov_judge/create_disk_images.py b/kpov_judge/create_disk_images.py
index b538775..566c4fe 100755
--- a/kpov_judge/create_disk_images.py
+++ b/kpov_judge/create_disk_images.py
@@ -16,7 +16,7 @@ from util import write_default_config
def get_prepare_disks(db, class_id, task_id):
prepare_disks_source = db.prepare_disks.find_one({'class_id': class_id, 'task_id':task_id})['source']
d = {}
- exec(compile(prepare_disks_source, 'prepare_disks.py', 'exec'), d)
+ exec(compile(prepare_disks_source, 'prepare_disks.py', 'exec'), globals(), d)
return d['prepare_disks']
def create_snapshot(class_id, task_id, student_id, disk_name, overwrite = True, cow = False):
diff --git a/kpov_judge/instructions_extractor.py b/kpov_judge/instructions_extractor.py
index b1644b2..f747c1a 100644
--- a/kpov_judge/instructions_extractor.py
+++ b/kpov_judge/instructions_extractor.py
@@ -22,8 +22,9 @@ def print_instructions(p, fname):
print(" - ".join(l1))
with open(os.path.join(p, fname)) as f:
task_code = compile(f.read(), fname, 'exec')
- exec(task_code)
- for lang, text in instructions.items():
+ d = {}
+ exec(task_code, globals(), d)
+ for lang, text in d['instructions'].items():
print("Language: {0}".format(lang))
print(text.encode('utf-8'))
print("")
diff --git a/kpov_judge/test_prepare_disks.py b/kpov_judge/test_prepare_disks.py
index 8d0d8c1..a03bb0c 100755
--- a/kpov_judge/test_prepare_disks.py
+++ b/kpov_judge/test_prepare_disks.py
@@ -159,7 +159,7 @@ if __name__ == '__main__':
req = urllib.request.Request("{task_url}/{task_name}/task.py".format(**params))
source = urllib.request.urlopen(req).read()
d = {}
- exec(compile(source, 'task.py', 'exec'), d)
+ exec(compile(source, 'task.py', 'exec'), globals(), d)
computers, prepare_disks = d['computers'], d['prepare_disks']
except Exception as e:
print(e)
diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py
index a3eace5..ad33b15 100755
--- a/kpov_judge/test_task.py
+++ b/kpov_judge/test_task.py
@@ -79,7 +79,7 @@ def load_task(stream):
# task_check and gen_params, and a dictionary params_meta
source = stream.read()
d = {}
- exec(compile(source, 'task.py', 'exec'), d)
+ exec(compile(source, 'task.py', 'exec'), globals(), d)
return d['task'], d['task_check'], d['params_meta'], d['gen_params']
def locate_task(params, argparser, quiet=False):
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index 5d3e791..b190567 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -91,7 +91,7 @@ def results_post(class_id, task_id, results):
try:
task_check_source = db.task_checkers.find_one({'class_id': class_id, 'task_id': task_id})['source']
d = {}
- exec(compile(task_check_source, 'checker.py', 'exec'), d)
+ exec(compile(task_check_source, 'checker.py', 'exec'), globals(), d)
# raise Exception(str(params))
res, hints = d['task_check'](results, params)
except Exception as e:
@@ -188,7 +188,7 @@ def get_params(class_id, task_id, student_id, db):
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')
d = {}
- exec(gen_params_code, d)
+ exec(gen_params_code, globals(), 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)