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/xmlrpc_clients.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'yaksh/xmlrpc_clients.py') diff --git a/yaksh/xmlrpc_clients.py b/yaksh/xmlrpc_clients.py index 6bfe0d6..83ba277 100644 --- a/yaksh/xmlrpc_clients.py +++ b/yaksh/xmlrpc_clients.py @@ -1,11 +1,19 @@ -from xmlrpclib import ServerProxy +from __future__ import absolute_import import time import random import socket import json import urllib +from six.moves import urllib -from settings import SERVER_PORTS, SERVER_POOL_PORT +try: + from xmlrpclib import ServerProxy +except ImportError: + # The above import will not work on Python-3.x. + from xmlrpc.client import ServerProxy + +# Local imports +from .settings import SERVER_PORTS, SERVER_POOL_PORT class ConnectionError(Exception): @@ -58,7 +66,8 @@ class CodeServerProxy(object): return result def _get_server(self): - port = json.loads(urllib.urlopen(self.pool_url).read()) + response = urllib.request.urlopen(self.pool_url) + port = json.loads(response.read().decode('utf-8')) proxy = ServerProxy('http://localhost:%d' % port) return proxy -- cgit From cb0569a32422a195d4165ef405ac5560024dabda Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 29 Sep 2016 18:10:09 +0530 Subject: Add unicode_literal import for Python2 --- yaksh/xmlrpc_clients.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/xmlrpc_clients.py') diff --git a/yaksh/xmlrpc_clients.py b/yaksh/xmlrpc_clients.py index 83ba277..4da70dd 100644 --- a/yaksh/xmlrpc_clients.py +++ b/yaksh/xmlrpc_clients.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import +from __future__ import unicode_literals import time import random import socket -- cgit