summaryrefslogtreecommitdiff
path: root/yaksh/code_evaluator.py
diff options
context:
space:
mode:
authorprathamesh2016-10-04 17:22:20 +0530
committerprathamesh2016-10-04 17:22:20 +0530
commit9c14e2b2026074234d9c977ca17b0c96b0789f6b (patch)
tree8b6c8e2438563e56631c2adf986e7cb16c33afb4 /yaksh/code_evaluator.py
parentc5ae3d4589a71c3f3b9f622c7b67a04277269cde (diff)
parent91dd42214ba5ad88c5158b50a7746caa3841a883 (diff)
downloadonline_test-9c14e2b2026074234d9c977ca17b0c96b0789f6b.tar.gz
online_test-9c14e2b2026074234d9c977ca17b0c96b0789f6b.tar.bz2
online_test-9c14e2b2026074234d9c977ca17b0c96b0789f6b.zip
Merge branch 'master' of https://github.com/FOSSEE/online_test into edit_questionpaper
Resolved Conflicts: yaksh/views.py
Diffstat (limited to 'yaksh/code_evaluator.py')
-rw-r--r--yaksh/code_evaluator.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/yaksh/code_evaluator.py b/yaksh/code_evaluator.py
index 8a9b7a6..870a67f 100644
--- a/yaksh/code_evaluator.py
+++ b/yaksh/code_evaluator.py
@@ -1,5 +1,6 @@
+#!/usr/bin/env python
+from __future__ import unicode_literals
import sys
-from SimpleXMLRPCServer import SimpleXMLRPCServer
import pwd
import os
import stat
@@ -9,8 +10,15 @@ import traceback
from multiprocessing import Process, Queue
import subprocess
import re
-# Local imports.
-from settings import SERVER_TIMEOUT
+
+try:
+ from SimpleXMLRPCServer import SimpleXMLRPCServer
+except ImportError:
+ # The above import will not work on Python-3.x.
+ from xmlrpc.server import SimpleXMLRPCServer
+
+# Local imports
+from .settings import SERVER_TIMEOUT
MY_DIR = abspath(dirname(__file__))
@@ -127,6 +135,7 @@ class CodeEvaluator(object):
def teardown(self):
# Cancel the signal
delete_signal_handler()
+ self._change_dir(dirname(MY_DIR))
def check_code(self):
raise NotImplementedError("check_code method not implemented")
@@ -176,7 +185,7 @@ class CodeEvaluator(object):
proc.kill()
# Re-raise exception.
raise
- return proc, stdout, stderr
+ return proc, stdout.decode('utf-8'), stderr.decode('utf-8')
def _change_dir(self, in_dir):
if in_dir is not None and isdir(in_dir):