diff --git a/hexonet/apiconnector/connection.py b/hexonet/apiconnector/connection.py index 6b91088..8f86a28 100755 --- a/hexonet/apiconnector/connection.py +++ b/hexonet/apiconnector/connection.py @@ -1,19 +1,7 @@ -import urllib +from six.moves.urllib import request +from six.moves import urlparse import apiconnector.util from apiconnector.response import Response -try: - # For Python 3.0 and later - from urllib.request import urlopen -except ImportError: - # Fall back to Python 2's urllib2 - from urllib2 import urlopen -try: - # For Python 3.0 and later - from urllib import parse as urlparse -except ImportError: - # Fall back to Python 2 - from urlparse import urlparse - """ APICONNECTOR Connection @@ -46,7 +34,7 @@ def call_raw_http(self, command, config=None): post['s_command'] = apiconnector.util.command_encode(command) post = urlparse.urlencode(post) - response = urlopen(self._config['url'], post.encode('UTF-8')) + response = request.urlopen(self._config['url'], post.encode('UTF-8')) content = response.read() return content diff --git a/hexonet/apiconnector/util.py b/hexonet/apiconnector/util.py index a50f010..f06ca98 100755 --- a/hexonet/apiconnector/util.py +++ b/hexonet/apiconnector/util.py @@ -1,13 +1,8 @@ import re -from datetime import datetime import time -try: - # For Python 3.0 and later - from urllib import parse as urlparse -except ImportError: - # Fall back to Python 2 - from urlparse import urlparse import base64 +from six.moves import urlparse +from datetime import datetime def command_encode(command):