summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2014-11-24 12:27:16 +0200
committerAlon Levy <alon@pobox.com>2014-11-24 12:27:16 +0200
commit12506bd331378a2582ff1e54f1b4e09910b7342d (patch)
tree73d9968b371220771d082ad01b537bdce24fc5e5
parent1045754c6e1b5587f09fef11be8b62094a29d697 (diff)
python3 compat: urllib
-rw-r--r--src-py/neo4j_util.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/src-py/neo4j_util.py b/src-py/neo4j_util.py
index 2b6257b4..1d0f0203 100644
--- a/src-py/neo4j_util.py
+++ b/src-py/neo4j_util.py
@@ -3,7 +3,8 @@
"""
import json
-import urllib2
+from six.moves.urllib import request
+import six.moves.urllib_error as urllib_error
import model
import string
import time
@@ -79,7 +80,7 @@ def post(url, data):
post_data_json = json.dumps(data)
- req = urllib2.Request(url)
+ req = request.Request(url)
req.add_header('User-Agent', 'rhizi-server/0.1')
req.add_header('Accept', 'application/json; charset=UTF-8')
req.add_header('Content-Type', 'application/json')
@@ -87,8 +88,8 @@ def post(url, data):
req.add_header('X-Stream', 'true') # enable neo4j JSON streaming
try:
- ret = urllib2.urlopen(req, post_data_json)
- except urllib2.HTTPError as e:
+ ret = request.urlopen(req, post_data_json)
+ except urllib_error.HTTPError as e:
raise Exception('post request failed: code: {0}, reason: {1}'.format(e.code, e.reason))
return ret