Commit fc4114e6 authored by Przemek Kaminski's avatar Przemek Kaminski

Python3 compatibility fixes

parent 6923f160
......@@ -28,5 +28,5 @@
#
##############################################################################
from main import *
from .main import *
......@@ -35,10 +35,16 @@ Home page: http://pypi.python.org/pypi/openerp-client-lib
Code repository: https://code.launchpad.net/~niv-openerp/openerp-client-lib/trunk
"""
import xmlrpclib
import sys
if sys.version_info >= (3, 0, 0):
from urllib.request import Request, urlopen
import xmlrpc as xmlrpclib
else:
from urllib2 import Request, urlopen
import xmlrpclib
import logging
import json
import urllib2
import random
_logger = logging.getLogger(__name__)
......@@ -107,10 +113,10 @@ def json_rpc(url, fct_name, params):
"params": params,
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url=url, data=json.dumps(data), headers={
req = Request(url=url, data=json.dumps(data), headers={
"Content-Type":"application/json",
})
result = urllib2.urlopen(req)
result = urlopen(req)
result = json.load(result)
if result.get("error", None):
raise JsonRPCException(result["error"])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment