diff options
author | Prabhu Ramachandran | 2016-10-04 15:44:05 +0530 |
---|---|---|
committer | GitHub | 2016-10-04 15:44:05 +0530 |
commit | 91dd42214ba5ad88c5158b50a7746caa3841a883 (patch) | |
tree | 188f8aa284783e844eccffe350839d6a18f4da8b /yaksh/xmlrpc_clients.py | |
parent | 6b08e56fe3cf70ffbcbd1ed432dde25babe48148 (diff) | |
parent | 59fa975a9fd0f6728cf62b1069abecac95a77b68 (diff) | |
download | online_test-91dd42214ba5ad88c5158b50a7746caa3841a883.tar.gz online_test-91dd42214ba5ad88c5158b50a7746caa3841a883.tar.bz2 online_test-91dd42214ba5ad88c5158b50a7746caa3841a883.zip |
Merge pull request #143 from adityacp/python2to3-migrate
Migration Python 2 to 3
Diffstat (limited to 'yaksh/xmlrpc_clients.py')
-rw-r--r-- | yaksh/xmlrpc_clients.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/yaksh/xmlrpc_clients.py b/yaksh/xmlrpc_clients.py index 6bfe0d6..4da70dd 100644 --- a/yaksh/xmlrpc_clients.py +++ b/yaksh/xmlrpc_clients.py @@ -1,11 +1,19 @@ -from xmlrpclib import ServerProxy +from __future__ import unicode_literals 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 |