Skip to content

Commit

Permalink
introduced six for py2 and py3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSchwarz-cnic committed Jul 9, 2018
1 parent a0f7e2f commit fa7403a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
18 changes: 3 additions & 15 deletions 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
Expand Down Expand Up @@ -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

Expand Down
9 changes: 2 additions & 7 deletions 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):
Expand Down

0 comments on commit fa7403a

Please sign in to comment.