From 12506bd331378a2582ff1e54f1b4e09910b7342d Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 24 Nov 2014 12:27:16 +0200 Subject: python3 compat: urllib --- src-py/neo4j_util.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src-py') 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 -- cgit v1.3.1