From ac8d6720bc75676e05462cc38ad144d5aedc14e7 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 21 Sep 2016 15:07:43 +0530 Subject: Migrate python code server and evaluators to python 2/3 compatible --- yaksh/code_server.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'yaksh/code_server.py') diff --git a/yaksh/code_server.py b/yaksh/code_server.py index e19e9c8..b753ac7 100755 --- a/yaksh/code_server.py +++ b/yaksh/code_server.py @@ -23,7 +23,7 @@ that returns an available server. """ # Standard library imports -from SimpleXMLRPCServer import SimpleXMLRPCServer +from __future__ import absolute_import import json from multiprocessing import Process, Queue import os @@ -35,6 +35,12 @@ import stat import subprocess import sys +try: + from SimpleXMLRPCServer import SimpleXMLRPCServer +except ImportError: + # The above import will not work on Python-3.x. + from xmlrpc.server import SimpleXMLRPCServer + try: from urllib import unquote except ImportError: @@ -45,9 +51,9 @@ except ImportError: from tornado.ioloop import IOLoop from tornado.web import Application, RequestHandler -# Local imports. -from settings import SERVER_PORTS, SERVER_POOL_PORT -from language_registry import create_evaluator_instance, unpack_json +# Local imports +from .settings import SERVER_PORTS, SERVER_POOL_PORT +from .language_registry import create_evaluator_instance, unpack_json MY_DIR = abspath(dirname(__file__)) -- cgit