diff options
author | Martin <martin@leo.fri1.uni-lj.si> | 2015-09-22 13:13:31 +0200 |
---|---|---|
committer | Martin <martin@leo.fri1.uni-lj.si> | 2015-09-22 13:13:31 +0200 |
commit | 68acd82d75106cddd3d4b79365672cad7391c3cd (patch) | |
tree | cc9448103c9a21bed694abe6f818a9eed8ecccb6 /server/handlers.py | |
parent | 63dff6d770ecb98d7f8f9337449b3450d3abb0de (diff) | |
parent | 2c61fec2140da5ec9a5aee8a7d6d3f0f2d3b0897 (diff) |
Merge branch 'master' of ssh://212.235.189.51:22122/codeq-server
Diffstat (limited to 'server/handlers.py')
-rw-r--r-- | server/handlers.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/server/handlers.py b/server/handlers.py index 52a33f5..08994a0 100644 --- a/server/handlers.py +++ b/server/handlers.py @@ -106,7 +106,27 @@ class Query(CodeqService): request.reply(result) -# Push stdin to the session's Python interpreter. TODO: convert to async handling +# Push user program to the Python interpreter to be exec'd. +class PythonExec(CodeqService): + def process(self, request): + program = request.data.get('program') + if program is None: + request.reply({'code': 1, 'message': 'No program specified'}) + else: + python = request.session.get_python() + python.exec(program) + request.reply({'code': 0, 'message': 'ok'}) + + +# Send an interrupt to the Python interpreter. +class PythonStop(CodeqService): + def process(self, request): + python = request.session.get_python() + python.stop() + request.reply({'code': 0, 'message': 'ok'}) + + +# Push stdin to the Python interpreter. class PythonPush(CodeqService): def process(self, request): text = request.data.get('text') @@ -194,7 +214,9 @@ incoming_handlers = { 'logout': None, 'activity': Activity(), 'query': Query(), + 'python_exec': PythonExec(), 'python_push': PythonPush(), + 'python_stop': PythonStop(), 'hint': Hint(), 'test': Test() } |