Use six.moves.urllib.parse for py2/3 compat
Instead of try/except blocks, just use the six module which is already in use in other places. Also remove a Python 2.5 compat construct. Python 2.5 is no longer supported. Change-Id: Idb13d861b0f8c567d1e44ce5bf6c60da12a24d18
This commit is contained in:
parent
35fc635556
commit
863b41053f
@ -23,24 +23,16 @@ from __future__ import print_function
|
||||
|
||||
import logging
|
||||
import os
|
||||
try:
|
||||
import urlparse
|
||||
except ImportError:
|
||||
import urllib.parse as urlparse
|
||||
|
||||
try:
|
||||
from eventlet import sleep
|
||||
except ImportError:
|
||||
from time import sleep # noqa
|
||||
|
||||
# Python 2.5 compat fix
|
||||
if not hasattr(urlparse, 'parse_qsl'):
|
||||
import cgi
|
||||
urlparse.parse_qsl = cgi.parse_qsl
|
||||
|
||||
from oslo.serialization import jsonutils
|
||||
from oslo.utils import importutils
|
||||
import requests
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from manilaclient import exceptions
|
||||
from manilaclient import service_catalog
|
||||
@ -296,7 +288,7 @@ class HTTPClient(object):
|
||||
self.keyring_saver.save_password()
|
||||
|
||||
def authenticate(self):
|
||||
magic_tuple = urlparse.urlsplit(self.auth_url)
|
||||
magic_tuple = parse.urlsplit(self.auth_url)
|
||||
scheme, netloc, path, query, frag = magic_tuple
|
||||
port = magic_tuple.port
|
||||
if port is None:
|
||||
@ -310,8 +302,8 @@ class HTTPClient(object):
|
||||
# TODO(sandy): Assume admin endpoint is 35357 for now.
|
||||
# Ideally this is going to have to be provided by the service catalog.
|
||||
new_netloc = netloc.replace(':%d' % port, ':%d' % (35357,))
|
||||
admin_url = urlparse.urlunsplit((scheme, new_netloc,
|
||||
path, query, frag))
|
||||
admin_url = parse.urlunsplit((scheme, new_netloc,
|
||||
path, query, frag))
|
||||
|
||||
auth_url = self.auth_url
|
||||
if self.version == "v2.0":
|
||||
|
@ -12,10 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
try:
|
||||
import urlparse
|
||||
except ImportError:
|
||||
import urllib.parse as urlparse
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from manilaclient import client as base_client
|
||||
from manilaclient.tests.unit import fakes
|
||||
@ -48,7 +45,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
assert 'body' in kwargs
|
||||
|
||||
# Call the method
|
||||
args = urlparse.parse_qsl(urlparse.urlparse(url)[4])
|
||||
args = parse.parse_qsl(parse.urlparse(url)[4])
|
||||
kwargs.update(args)
|
||||
munged_url = url.rsplit('?', 1)[0]
|
||||
munged_url = munged_url.strip('/').replace('/', '_').replace('.', '_')
|
||||
|
Loading…
Reference in New Issue
Block a user