Merge "It was removed urllib, urllib2 & urlparse modules"
This commit is contained in:
@@ -20,10 +20,10 @@ import logging
|
||||
import posixpath
|
||||
import socket
|
||||
import struct
|
||||
import urlparse
|
||||
|
||||
import six
|
||||
from six.moves import http_client
|
||||
from six.moves.urllib import parse
|
||||
|
||||
try:
|
||||
import json
|
||||
@@ -31,9 +31,9 @@ except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
# Python 2.5 compat fix
|
||||
if not hasattr(urlparse, 'parse_qsl'):
|
||||
if not hasattr(parse, 'parse_qsl'):
|
||||
import cgi
|
||||
urlparse.parse_qsl = cgi.parse_qsl
|
||||
parse.parse_qsl = cgi.parse_qsl
|
||||
|
||||
import OpenSSL
|
||||
|
||||
@@ -85,7 +85,7 @@ class HTTPClient(object):
|
||||
|
||||
@staticmethod
|
||||
def parse_endpoint(endpoint):
|
||||
return urlparse.urlparse(endpoint)
|
||||
return parse.urlparse(endpoint)
|
||||
|
||||
@staticmethod
|
||||
def get_connection_class(scheme):
|
||||
@@ -199,14 +199,14 @@ class HTTPClient(object):
|
||||
# v1/images/detail' from recursion.
|
||||
# See bug #1230032 and bug #1208618.
|
||||
if url is not None:
|
||||
all_parts = urlparse.urlparse(url)
|
||||
all_parts = parse.urlparse(url)
|
||||
if not (all_parts.scheme and all_parts.netloc):
|
||||
norm_parse = posixpath.normpath
|
||||
url = norm_parse('/'.join([self.endpoint_path, url]))
|
||||
else:
|
||||
url = self.endpoint_path
|
||||
|
||||
conn_url = urlparse.urlsplit(url).geturl()
|
||||
conn_url = parse.urlsplit(url).geturl()
|
||||
# Note(flaper87): Ditto, headers / url
|
||||
# encoding to make httplib happy.
|
||||
conn_url = strutils.safe_encode(conn_url)
|
||||
|
@@ -15,8 +15,9 @@
|
||||
|
||||
import copy
|
||||
import json
|
||||
|
||||
import six
|
||||
import urllib
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from glanceclient.common import base
|
||||
from glanceclient.common import utils
|
||||
@@ -112,7 +113,7 @@ class ImageManager(base.Manager):
|
||||
|
||||
image_id = base.getid(image)
|
||||
resp, body = self.api.raw_request('HEAD', '/v1/images/%s'
|
||||
% urllib.quote(str(image_id)))
|
||||
% parse.quote(str(image_id)))
|
||||
meta = self._image_meta_from_headers(dict(resp.getheaders()))
|
||||
return Image(self, meta)
|
||||
|
||||
@@ -125,7 +126,7 @@ class ImageManager(base.Manager):
|
||||
"""
|
||||
image_id = base.getid(image)
|
||||
resp, body = self.api.raw_request('GET', '/v1/images/%s'
|
||||
% urllib.quote(str(image_id)))
|
||||
% parse.quote(str(image_id)))
|
||||
checksum = resp.getheader('x-image-meta-checksum', None)
|
||||
if do_checksum and checksum is not None:
|
||||
body.set_checksum(checksum)
|
||||
@@ -171,7 +172,7 @@ class ImageManager(base.Manager):
|
||||
# trying to encode them
|
||||
qp[param] = strutils.safe_encode(value)
|
||||
|
||||
url = '/v1/images/detail?%s' % urllib.urlencode(qp)
|
||||
url = '/v1/images/detail?%s' % parse.urlencode(qp)
|
||||
images = self._list(url, "images")
|
||||
for image in images:
|
||||
if filter_owner(owner, image):
|
||||
|
@@ -22,7 +22,8 @@ from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import urlparse
|
||||
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from glanceclient.common import utils
|
||||
|
||||
@@ -75,7 +76,7 @@ def print_image_formatted(client, image):
|
||||
:param client: The Glance client object
|
||||
:param image: The image metadata
|
||||
"""
|
||||
uri_parts = urlparse.urlparse(client.http_client.endpoint)
|
||||
uri_parts = parse.urlparse(client.http_client.endpoint)
|
||||
if uri_parts.port:
|
||||
hostbase = "%s:%s" % (uri_parts.hostname, uri_parts.port)
|
||||
else:
|
||||
|
@@ -14,7 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import urllib
|
||||
from six.moves.urllib import parse
|
||||
|
||||
import warlock
|
||||
|
||||
@@ -64,10 +64,10 @@ class Controller(object):
|
||||
if isinstance(value, six.string_types):
|
||||
filters[param] = strutils.safe_encode(value)
|
||||
|
||||
url = '/v2/images?%s' % urllib.urlencode(filters)
|
||||
url = '/v2/images?%s' % parse.urlencode(filters)
|
||||
|
||||
for param in tags_url_params:
|
||||
url = '%s&%s' % (url, urllib.urlencode(param))
|
||||
url = '%s&%s' % (url, parse.urlencode(param))
|
||||
|
||||
for image in paginate(url):
|
||||
#NOTE(bcwaldon): remove 'self' for now until we have an elegant
|
||||
|
@@ -15,16 +15,16 @@
|
||||
|
||||
import errno
|
||||
import socket
|
||||
import urlparse
|
||||
|
||||
from mox3 import mox
|
||||
import six
|
||||
from six.moves import http_client
|
||||
from six.moves.urllib import parse
|
||||
import testtools
|
||||
|
||||
import glanceclient
|
||||
from glanceclient.common import http
|
||||
from glanceclient import exc
|
||||
from six.moves import http_client
|
||||
from tests import utils
|
||||
|
||||
|
||||
@@ -221,9 +221,9 @@ class TestClient(testtools.TestCase):
|
||||
endpoint = 'http://example.com:9292'
|
||||
test_client = http.HTTPClient(endpoint, token=u'adc123')
|
||||
actual = test_client.parse_endpoint(endpoint)
|
||||
expected = urlparse.ParseResult(scheme='http',
|
||||
netloc='example.com:9292', path='',
|
||||
params='', query='', fragment='')
|
||||
expected = parse.ParseResult(scheme='http',
|
||||
netloc='example.com:9292', path='',
|
||||
params='', query='', fragment='')
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_get_connection_class(self):
|
||||
|
@@ -17,9 +17,9 @@ import errno
|
||||
import json
|
||||
import sys
|
||||
import testtools
|
||||
import urlparse
|
||||
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
|
||||
from glanceclient.v1 import client
|
||||
from glanceclient.v1 import images
|
||||
@@ -769,8 +769,8 @@ class UrlParameterTest(testtools.TestCase):
|
||||
|
||||
def test_is_public_list(self):
|
||||
shell.do_image_list(self.gc, FakeArg({"is_public": "True"}))
|
||||
parts = urlparse.urlparse(self.api.url)
|
||||
qs_dict = urlparse.parse_qs(parts.query)
|
||||
parts = parse.urlparse(self.api.url)
|
||||
qs_dict = parse.parse_qs(parts.query)
|
||||
self.assertTrue('is_public' in qs_dict)
|
||||
self.assertTrue(qs_dict['is_public'][0].lower() == "true")
|
||||
|
||||
|
Reference in New Issue
Block a user