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