summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge')
-rwxr-xr-xkpov_judge/test_prepare_disks.py6
-rwxr-xr-xkpov_judge/test_task.py7
-rwxr-xr-xkpov_judge/web/kpov_judge/kpov_judge.py22
3 files changed, 12 insertions, 23 deletions
diff --git a/kpov_judge/test_prepare_disks.py b/kpov_judge/test_prepare_disks.py
index 7cfc5b5..bdb3f89 100755
--- a/kpov_judge/test_prepare_disks.py
+++ b/kpov_judge/test_prepare_disks.py
@@ -146,6 +146,7 @@ if __name__ == '__main__':
print("Usage: " + sys.argv[0])
print("Run prepare_disks on running computers over ssh")
print("The task name and params are read from ~/.kpov_params.yaml")
+
yaml_config_file = os.path.expanduser("~/.kpov_params.yaml")
with open(yaml_config_file) as f:
params = yaml.load(f)
@@ -157,12 +158,15 @@ if __name__ == '__main__':
http_auth(task_url, params['username'], params['password'])
req = urllib.request.Request("{task_url}/{task_name}/task.py".format(**params))
source = urllib.request.urlopen(req).read()
+ if not source:
+ raise Exception('no such task: {}'.format(task_name))
d = {}
exec(compile(source, 'task.py', 'exec'), globals(), d)
computers, prepare_disks = d['computers'], d['prepare_disks']
except Exception as e:
print(e)
- exit(1)
+ exit(1)
+
templates = dict()
sshguestfs_params = params.get('sshguestfs_params', dict())
task_sshguestfs_params = sshguestfs_params.get(task_name, dict())
diff --git a/kpov_judge/test_task.py b/kpov_judge/test_task.py
index a049bee..a1f3608 100755
--- a/kpov_judge/test_task.py
+++ b/kpov_judge/test_task.py
@@ -141,11 +141,12 @@ if __name__ == '__main__':
task_url = params['task_url']
task_name = params['task_name']
- source = urllib.request.urlopen("{task_url}/{task_name}/task.py".format(**params))
+ source = urllib.request.urlopen("{task_url}/{task_name}/task.py".format(**params)).read()
+ if not source:
+ raise Exception('no such task: {}'.format(task_name))
task, task_check, task_params_meta, gen_params = load_task(source)
except Exception as e:
- import traceback
- traceback.print_exc()
+ print(e)
with open(basic_args.params_file, 'w') as f:
yaml.dump(params, f)
exit(1)
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index 7415724..47e413e 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -30,21 +30,6 @@ def get_locale():
return 'sl'
return request.accept_languages.best_match(['sl', 'en'])
-dummy_task = """
-def task(neznano_ime_naloge):
- print "Ta naloga ne obstaja!"
- return {'odgovor': 'neznana naloga'}
-
-def task_check(results, params):
- raise Exception("neznana naloga?")
- return "Manjka preverjalnik naloge (neznana naloga?)"
-
-def gen_params(user_id, meta):
- return dict()
-
-params_meta = {'neznano_ime_naloge': {'opis':'NEZNANA NALOGA', 'w': False}}
-"""
-
@app.before_request
def before_request():
@@ -89,10 +74,9 @@ def setup_svg(class_id, task_id, lang, ending):
def task_source(class_id, task_id):
db = g.db
try:
- task_str = db.tasks.find_one({'class_id': class_id, 'task_id': task_id})['source']
- except Exception:
- return dummy_task
- return task_str
+ return db.tasks.find_one({'class_id': class_id, 'task_id': task_id})['source']
+ except:
+ return ''
@app.route('/tasks/<class_id>/<task_id>/task.html')