diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-10-06 14:43:48 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2016-10-06 14:43:48 +0200 |
commit | bd170fb7b4dbfc8eb3a18ecd6cdd437d5e11b5ed (patch) | |
tree | 58cd7f16af2e938f7a8d64d2544cf6bb683c9e05 /server/handlers.py | |
parent | 54a679161a9cd39570b566e9236d85774d7c6d8f (diff) |
Python: add support for auxiliary code (like for Prolog)
Diffstat (limited to 'server/handlers.py')
-rw-r--r-- | server/handlers.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/server/handlers.py b/server/handlers.py index 5e06463..7e27d55 100644 --- a/server/handlers.py +++ b/server/handlers.py @@ -1,5 +1,5 @@ # CodeQ: an online programming tutor. -# Copyright (C) 2015 UL FRI +# Copyright (C) 2015,2016 UL FRI # # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by the Free @@ -195,15 +195,19 @@ class Query(CodeqService): # Push user program to the Python interpreter to be exec'd. class PythonExec(CodeqService): def process(self, request): - program = request.data.get('program') - python = request.session.current_language_session() - if program is None: - request.reply({'code': 1, 'message': 'No program specified'}) - elif not isinstance(python, server.python_session.PythonSession): - request.reply({'code': 2, 'message': 'The currently active session is not Python'}) + problem_id = request.data.get('problem_id') + if problem_id is None: + request.reply({'code': 4, 'message': 'Problem ID not given'}) else: - python.exec(program) - request.reply({'code': 0, 'message': 'ok'}) + program = request.data.get('program') + python = request.session.current_language_session() + if program is None: + request.reply({'code': 1, 'message': 'No program specified'}) + elif not isinstance(python, server.python_session.PythonSession): + request.reply({'code': 2, 'message': 'The currently active session is not Python'}) + else: + python.exec(program, problem_id) + request.reply({'code': 0, 'message': 'ok'}) # Send an interrupt to the Python interpreter. |