summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/swift-account-audit2
-rw-r--r--swift/cli/info.py7
-rw-r--r--swift/cli/recon.py2
-rw-r--r--swift/common/bufferedhttp.py2
-rw-r--r--swift/common/constraints.py6
-rw-r--r--swift/common/internal_client.py4
-rw-r--r--swift/common/middleware/bulk.py2
-rw-r--r--swift/common/middleware/dlo.py2
-rw-r--r--swift/common/middleware/formpost.py2
-rw-r--r--swift/common/middleware/list_endpoints.py3
-rw-r--r--swift/common/middleware/name_check.py3
-rw-r--r--swift/common/middleware/proxy_logging.py2
-rw-r--r--swift/common/middleware/tempauth.py2
-rw-r--r--swift/common/middleware/tempurl.py5
-rw-r--r--swift/common/middleware/versioned_writes.py2
-rw-r--r--swift/common/request_helpers.py2
-rw-r--r--swift/common/wsgi.py2
-rw-r--r--swift/obj/expirer.py5
-rw-r--r--swift/obj/ssync_receiver.py9
-rw-r--r--swift/obj/ssync_sender.py11
-rw-r--r--swift/proxy/controllers/account.py3
-rw-r--r--swift/proxy/controllers/base.py3
-rw-r--r--swift/proxy/controllers/container.py2
-rw-r--r--swift/proxy/controllers/obj.py3
-rw-r--r--test/functional/__init__.py2
-rw-r--r--test/functional/swift_test_client.py14
-rw-r--r--test/functional/tests.py10
-rw-r--r--test/probe/brain.py2
-rwxr-xr-xtest/probe/test_account_get_fake_responses_match.py2
-rw-r--r--test/probe/test_container_sync.py2
-rw-r--r--test/unit/cli/test_recon.py4
-rw-r--r--test/unit/common/middleware/test_bulk.py11
-rw-r--r--test/unit/common/middleware/test_proxy_logging.py2
-rw-r--r--test/unit/common/test_direct_client.py8
-rw-r--r--test/unit/common/test_internal_client.py2
-rw-r--r--test/unit/common/test_swob.py2
-rw-r--r--test/unit/common/test_wsgi.py2
-rw-r--r--test/unit/container/test_reconciler.py8
-rw-r--r--test/unit/obj/test_expirer.py4
-rw-r--r--test/unit/obj/test_ssync_sender.py7
-rw-r--r--test/unit/proxy/test_server.py3
-rw-r--r--test/unit/proxy/test_sysmeta.py4
42 files changed, 96 insertions, 79 deletions
diff --git a/bin/swift-account-audit b/bin/swift-account-audit
index aa3bce477..93c8c8c04 100755
--- a/bin/swift-account-audit
+++ b/bin/swift-account-audit
@@ -16,7 +16,6 @@
import os
import sys
-from urllib import quote
from hashlib import md5
import getopt
from itertools import chain
@@ -24,6 +23,7 @@ from itertools import chain
import simplejson
from eventlet.greenpool import GreenPool
from eventlet.event import Event
+from six.moves.urllib.parse import quote
from swift.common.ring import Ring
from swift.common.utils import split_path
diff --git a/swift/cli/info.py b/swift/cli/info.py
index eed4dea16..ba02cfd25 100644
--- a/swift/cli/info.py
+++ b/swift/cli/info.py
@@ -14,9 +14,10 @@ from __future__ import print_function
import itertools
import os
import sqlite3
-import urllib
from hashlib import md5
+from six.moves import urllib
+
from swift.common.utils import hash_path, storage_directory, \
Timestamp
from swift.common.ring import Ring
@@ -100,7 +101,7 @@ def print_ring_locations(ring, datadir, account, container=None, obj=None,
for node in primary_nodes:
cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
% (node['ip'], node['port'], node['device'], part,
- urllib.quote(target))
+ urllib.parse.quote(target))
if policy_index is not None:
cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index',
policy_index)
@@ -108,7 +109,7 @@ def print_ring_locations(ring, datadir, account, container=None, obj=None,
for node in handoff_nodes:
cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
% (node['ip'], node['port'], node['device'], part,
- urllib.quote(target))
+ urllib.parse.quote(target))
if policy_index is not None:
cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index',
policy_index)
diff --git a/swift/cli/recon.py b/swift/cli/recon.py
index 6c5894a5a..f77a00ff0 100644
--- a/swift/cli/recon.py
+++ b/swift/cli/recon.py
@@ -19,9 +19,9 @@
from __future__ import print_function
from eventlet.green import urllib2
+from six.moves.urllib.parse import urlparse
from swift.common.utils import SWIFT_CONF_FILE
from swift.common.ring import Ring
-from urlparse import urlparse
from hashlib import md5
import eventlet
import json
diff --git a/swift/common/bufferedhttp.py b/swift/common/bufferedhttp.py
index d5c149ad9..2db36b155 100644
--- a/swift/common/bufferedhttp.py
+++ b/swift/common/bufferedhttp.py
@@ -28,7 +28,6 @@ BufferedHTTPResponse.
from swift import gettext_ as _
from swift.common import constraints
-from urllib import quote
import logging
import time
import socket
@@ -36,6 +35,7 @@ import socket
import eventlet
from eventlet.green.httplib import CONTINUE, HTTPConnection, HTTPMessage, \
HTTPResponse, HTTPSConnection, _UNKNOWN
+from six.moves.urllib.parse import quote
import six
httplib = eventlet.import_patched('httplib')
diff --git a/swift/common/constraints.py b/swift/common/constraints.py
index f36edb6f8..b72ed42c0 100644
--- a/swift/common/constraints.py
+++ b/swift/common/constraints.py
@@ -15,12 +15,12 @@
import functools
import os
-import urllib
import time
-from urllib import unquote
import six
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
+from six.moves import urllib
+from six.moves.urllib.parse import unquote
from swift.common import utils, exceptions
from swift.common.swob import HTTPBadRequest, HTTPLengthRequired, \
@@ -246,7 +246,7 @@ def check_mount(root, drive):
:param drive: drive name to be checked
:returns: True if it is a valid mounted device, False otherwise
"""
- if not (urllib.quote_plus(drive) == drive):
+ if not (urllib.parse.quote_plus(drive) == drive):
return False
path = os.path.join(root, drive)
return utils.ismount(path)
diff --git a/swift/common/internal_client.py b/swift/common/internal_client.py
index 2c9cc67e8..6e829b7b6 100644
--- a/swift/common/internal_client.py
+++ b/swift/common/internal_client.py
@@ -17,12 +17,12 @@ from eventlet import sleep, Timeout
from eventlet.green import httplib, socket, urllib2
import json
from six.moves import range
+from six.moves import urllib
import struct
from sys import exc_info
import zlib
from swift import gettext_ as _
from time import gmtime, strftime, time
-import urlparse
from zlib import compressobj
from swift.common.utils import quote
@@ -760,7 +760,7 @@ class SimpleClient(object):
req = urllib2.Request(url, headers=headers, data=contents)
if proxy:
- proxy = urlparse.urlparse(proxy)
+ proxy = urllib.parse.urlparse(proxy)
req.set_proxy(proxy.netloc, proxy.scheme)
req.get_method = lambda: method
conn = urllib2.urlopen(req, timeout=timeout)
diff --git a/swift/common/middleware/bulk.py b/swift/common/middleware/bulk.py
index d36306838..1d4199b08 100644
--- a/swift/common/middleware/bulk.py
+++ b/swift/common/middleware/bulk.py
@@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from six.moves.urllib.parse import quote, unquote
import tarfile
-from urllib import quote, unquote
from xml.sax import saxutils
from time import time
from eventlet import sleep
diff --git a/swift/common/middleware/dlo.py b/swift/common/middleware/dlo.py
index eed0b566a..2cf8f2fc9 100644
--- a/swift/common/middleware/dlo.py
+++ b/swift/common/middleware/dlo.py
@@ -17,6 +17,7 @@ import os
import six
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
+from six.moves.urllib.parse import unquote
from hashlib import md5
from swift.common import constraints
@@ -29,7 +30,6 @@ from swift.common.utils import get_logger, json, \
closing_if_possible
from swift.common.request_helpers import SegmentedIterable
from swift.common.wsgi import WSGIContext, make_subrequest
-from urllib import unquote
class GetContext(WSGIContext):
diff --git a/swift/common/middleware/formpost.py b/swift/common/middleware/formpost.py
index a30fa1a2f..e283478a9 100644
--- a/swift/common/middleware/formpost.py
+++ b/swift/common/middleware/formpost.py
@@ -115,8 +115,8 @@ __all__ = ['FormPost', 'filter_factory', 'READ_CHUNK_SIZE', 'MAX_VALUE_LENGTH']
import hmac
from hashlib import sha1
from time import time
-from urllib import quote
+from six.moves.urllib.parse import quote
from swift.common.exceptions import MimeInvalid
from swift.common.middleware.tempurl import get_tempurl_keys_from_metadata
from swift.common.utils import streq_const_time, register_swift_info, \
diff --git a/swift/common/middleware/list_endpoints.py b/swift/common/middleware/list_endpoints.py
index 37594b3b3..fb41bb6dd 100644
--- a/swift/common/middleware/list_endpoints.py
+++ b/swift/common/middleware/list_endpoints.py
@@ -78,7 +78,8 @@ with this middleware enabled should not be open to an untrusted
environment (everyone can query the locality data using this middleware).
"""
-from urllib import quote, unquote
+
+from six.moves.urllib.parse import quote, unquote
from swift.common.ring import Ring
from swift.common.utils import json, get_logger, split_path
diff --git a/swift/common/middleware/name_check.py b/swift/common/middleware/name_check.py
index d9431a75c..c2ddbbaf0 100644
--- a/swift/common/middleware/name_check.py
+++ b/swift/common/middleware/name_check.py
@@ -40,9 +40,10 @@ The filter returns HTTPBadRequest if path is invalid.
@author: eamonn-otoole
'''
+from six.moves.urllib.parse import unquote
+
import re
from swift.common.utils import get_logger
-from urllib2 import unquote
from swift.common.swob import Request, HTTPBadRequest
diff --git a/swift/common/middleware/proxy_logging.py b/swift/common/middleware/proxy_logging.py
index 79a4ed967..70c77fb15 100644
--- a/swift/common/middleware/proxy_logging.py
+++ b/swift/common/middleware/proxy_logging.py
@@ -73,8 +73,8 @@ bandwidth usage will want to only sum up logs with no swift.source.
import sys
import time
-from urllib import quote, unquote
+from six.moves.urllib.parse import quote, unquote
from swift.common.swob import Request
from swift.common.utils import (get_logger, get_remote_client,
get_valid_utf8_str, config_true_value,
diff --git a/swift/common/middleware/tempauth.py b/swift/common/middleware/tempauth.py
index 2b517ac9a..4a3b2b0ec 100644
--- a/swift/common/middleware/tempauth.py
+++ b/swift/common/middleware/tempauth.py
@@ -17,13 +17,13 @@ from __future__ import print_function
from time import time
from traceback import format_exc
-from urllib import unquote
from uuid import uuid4
from hashlib import sha1
import hmac
import base64
from eventlet import Timeout
+from six.moves.urllib.parse import unquote
from swift.common.swob import Response, Request
from swift.common.swob import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \
HTTPUnauthorized
diff --git a/swift/common/middleware/tempurl.py b/swift/common/middleware/tempurl.py
index 10278bf7b..59d9d4427 100644
--- a/swift/common/middleware/tempurl.py
+++ b/swift/common/middleware/tempurl.py
@@ -118,8 +118,9 @@ __all__ = ['TempURL', 'filter_factory',
from os.path import basename
from time import time
-from urllib import urlencode
-from urlparse import parse_qs
+
+from six.moves.urllib.parse import parse_qs
+from six.moves.urllib.parse import urlencode
from swift.proxy.controllers.base import get_account_info, get_container_info
from swift.common.swob import HeaderKeyDict, HTTPUnauthorized, HTTPBadRequest
diff --git a/swift/common/middleware/versioned_writes.py b/swift/common/middleware/versioned_writes.py
index bac923312..4c2f8a7d3 100644
--- a/swift/common/middleware/versioned_writes.py
+++ b/swift/common/middleware/versioned_writes.py
@@ -114,8 +114,8 @@ Disable versioning from a container (x is any value except empty)::
"""
import six
+from six.moves.urllib.parse import quote, unquote
import time
-from urllib import quote, unquote
from swift.common.utils import get_logger, Timestamp, json, \
register_swift_info, config_true_value
from swift.common.request_helpers import get_sys_meta_prefix
diff --git a/swift/common/request_helpers.py b/swift/common/request_helpers.py
index 6d02463e6..e30ce94eb 100644
--- a/swift/common/request_helpers.py
+++ b/swift/common/request_helpers.py
@@ -24,9 +24,9 @@ import hashlib
import itertools
import sys
import time
-from urllib import unquote
import six
+from six.moves.urllib.parse import unquote
from swift import gettext_ as _
from swift.common.storage_policy import POLICIES
diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py
index e7504355b..5d8ded023 100644
--- a/swift/common/wsgi.py
+++ b/swift/common/wsgi.py
@@ -33,7 +33,7 @@ from paste.deploy import loadwsgi
from eventlet.green import socket, ssl, os as green_os
from six import BytesIO
from six import StringIO
-from urllib import unquote
+from six.moves.urllib.parse import unquote
from swift.common import utils, constraints
from swift.common.storage_policy import BindPortsCache
diff --git a/swift/obj/expirer.py b/swift/obj/expirer.py
index d9b124d49..7f26f129c 100644
--- a/swift/obj/expirer.py
+++ b/swift/obj/expirer.py
@@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import urllib
+from six.moves import urllib
+
from random import random
from time import time
from os.path import join
@@ -290,7 +291,7 @@ class ObjectExpirer(Daemon):
:param timestamp: The timestamp the X-Delete-At value must match to
perform the actual delete.
"""
- path = '/v1/' + urllib.quote(actual_obj.lstrip('/'))
+ path = '/v1/' + urllib.parse.quote(actual_obj.lstrip('/'))
self.swift.make_request('DELETE', path,
{'X-If-Delete-At': str(timestamp)},
(2, HTTP_PRECONDITION_FAILED))
diff --git a/swift/obj/ssync_receiver.py b/swift/obj/ssync_receiver.py
index 7e00e8451..5f6b7d3b0 100644
--- a/swift/obj/ssync_receiver.py
+++ b/swift/obj/ssync_receiver.py
@@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import urllib
import eventlet
import eventlet.wsgi
import eventlet.greenio
+from six.moves import urllib
from swift.common import exceptions
from swift.common import http
@@ -38,11 +38,12 @@ def decode_missing(line):
"""
result = {}
parts = line.split()
- result['object_hash'], t_data = (urllib.unquote(v) for v in parts[:2])
+ result['object_hash'] = urllib.parse.unquote(parts[0])
+ t_data = urllib.parse.unquote(parts[1])
result['ts_data'] = result['ts_meta'] = Timestamp(t_data)
if len(parts) > 2:
# allow for a comma separated list of k:v pairs to future-proof
- subparts = urllib.unquote(parts[2]).split(',')
+ subparts = urllib.parse.unquote(parts[2]).split(',')
for item in [subpart for subpart in subparts if ':' in subpart]:
k, v = item.split(':')
if k == 'm':
@@ -78,7 +79,7 @@ def encode_wanted(remote, local):
# this is the inverse of _decode_wanted's key_map
key_map = dict(data='d', meta='m')
parts = ''.join(v for k, v in sorted(key_map.items()) if want.get(k))
- return '%s %s' % (urllib.quote(remote['object_hash']), parts)
+ return '%s %s' % (urllib.parse.quote(remote['object_hash']), parts)
return None
diff --git a/swift/obj/ssync_sender.py b/swift/obj/ssync_sender.py
index 82a1ae4b1..0003a0c05 100644
--- a/swift/obj/ssync_sender.py
+++ b/swift/obj/ssync_sender.py
@@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import urllib
+from six.moves import urllib
+
from itertools import ifilter
from swift.common import bufferedhttp
from swift.common import exceptions
@@ -29,7 +30,9 @@ def encode_missing(object_hash, ts_data, ts_meta=None):
The decoder for this line is
:py:func:`~swift.obj.ssync_receiver.decode_missing`
"""
- msg = '%s %s' % (urllib.quote(object_hash), urllib.quote(ts_data.internal))
+ msg = ('%s %s'
+ % (urllib.parse.quote(object_hash),
+ urllib.parse.quote(ts_data.internal)))
if ts_meta and ts_meta != ts_data:
delta = ts_meta.raw - ts_data.raw
msg = '%s m:%x' % (msg, delta)
@@ -318,14 +321,14 @@ class Sender(object):
msg = ':UPDATES: START\r\n'
self.connection.send('%x\r\n%s\r\n' % (len(msg), msg))
for object_hash, want in self.send_map.items():
- object_hash = urllib.unquote(object_hash)
+ object_hash = urllib.parse.unquote(object_hash)
try:
df = self.df_mgr.get_diskfile_from_hash(
self.job['device'], self.job['partition'], object_hash,
self.job['policy'], frag_index=self.job.get('frag_index'))
except exceptions.DiskFileNotExist:
continue
- url_path = urllib.quote(
+ url_path = urllib.parse.quote(
'/%s/%s/%s' % (df.account, df.container, df.obj))
try:
df.open()
diff --git a/swift/proxy/controllers/account.py b/swift/proxy/controllers/account.py
index 915e1c481..25cbc6218 100644
--- a/swift/proxy/controllers/account.py
+++ b/swift/proxy/controllers/account.py
@@ -13,8 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from six.moves.urllib.parse import unquote
+
from swift import gettext_ as _
-from urllib import unquote
from swift.account.utils import account_listing_response
from swift.common.request_helpers import get_listing_content_type
diff --git a/swift/proxy/controllers/base.py b/swift/proxy/controllers/base.py
index 72842a433..0213f41e5 100644
--- a/swift/proxy/controllers/base.py
+++ b/swift/proxy/controllers/base.py
@@ -24,6 +24,8 @@
# These shenanigans are to ensure all related objects can be garbage
# collected. We've seen objects hang around forever otherwise.
+from six.moves.urllib.parse import quote
+
import os
import time
import functools
@@ -32,7 +34,6 @@ import itertools
import operator
from sys import exc_info
from swift import gettext_ as _
-from urllib import quote
from eventlet import sleep
from eventlet.timeout import Timeout
diff --git a/swift/proxy/controllers/container.py b/swift/proxy/controllers/container.py
index 3e4a2bb03..d5e52618c 100644
--- a/swift/proxy/controllers/container.py
+++ b/swift/proxy/controllers/container.py
@@ -14,9 +14,9 @@
# limitations under the License.
from swift import gettext_ as _
-from urllib import unquote
import time
+from six.moves.urllib.parse import unquote
from swift.common.utils import public, csv_append, Timestamp
from swift.common.constraints import check_metadata
from swift.common import constraints
diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py
index bdb2028f3..5a8f3163d 100644
--- a/swift/proxy/controllers/obj.py
+++ b/swift/proxy/controllers/obj.py
@@ -24,6 +24,8 @@
# These shenanigans are to ensure all related objects can be garbage
# collected. We've seen objects hang around forever otherwise.
+from six.moves.urllib.parse import unquote, quote
+
import collections
import itertools
import mimetypes
@@ -32,7 +34,6 @@ import math
import random
from hashlib import md5
from swift import gettext_ as _
-from urllib import unquote, quote
from greenlet import GreenletExit
from eventlet import GreenPile
diff --git a/test/functional/__init__.py b/test/functional/__init__.py
index f07d16269..242a4667a 100644
--- a/test/functional/__init__.py
+++ b/test/functional/__init__.py
@@ -16,6 +16,7 @@
from __future__ import print_function
import mock
import os
+from six.moves.urllib.parse import urlparse
import sys
import pickle
import socket
@@ -26,7 +27,6 @@ import functools
import random
from time import time, sleep
-from urlparse import urlparse
from nose import SkipTest
from contextlib import closing
from gzip import GzipFile
diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py
index 0148ba7b3..68dcbea01 100644
--- a/test/functional/swift_test_client.py
+++ b/test/functional/swift_test_client.py
@@ -18,7 +18,6 @@ import os
import random
import socket
import time
-import urllib
import simplejson as json
from nose import SkipTest
@@ -26,6 +25,7 @@ from xml.dom import minidom
import six
from six.moves import http_client
+from six.moves import urllib
from swiftclient import get_auth
from swift.common import constraints
@@ -220,7 +220,7 @@ class Connection(object):
return '/' + self.storage_url.split('/')[1]
if path:
- quote = urllib.quote
+ quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_path_quote'):
quote = lambda x: x
return '%s/%s' % (self.storage_url,
@@ -260,7 +260,7 @@ class Connection(object):
path = self.make_path(path, cfg=cfg)
headers = self.make_headers(hdrs, cfg=cfg)
if isinstance(parms, dict) and parms:
- quote = urllib.quote
+ quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_parms_quote'):
quote = lambda x: x
query_args = ['%s=%s' % (quote(x), quote(str(y)))
@@ -328,7 +328,7 @@ class Connection(object):
headers.pop('Content-Length', None)
if isinstance(parms, dict) and parms:
- quote = urllib.quote
+ quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_parms_quote'):
quote = lambda x: x
query_args = ['%s=%s' % (quote(x), quote(str(y)))
@@ -698,7 +698,7 @@ class File(Base):
headers.update(hdrs)
if 'Destination' in headers:
- headers['Destination'] = urllib.quote(headers['Destination'])
+ headers['Destination'] = urllib.parse.quote(headers['Destination'])
return self.conn.make_request('COPY', self.path, hdrs=headers,
parms=parms) == 201
@@ -722,9 +722,9 @@ class File(Base):
if 'Destination-Account' in headers:
headers['Destination-Account'] = \
- urllib.quote(headers['Destination-Account'])
+ urllib.parse.quote(headers['Destination-Account'])
if 'Destination' in headers:
- headers['Destination'] = urllib.quote(headers['Destination'])
+ headers['Destination'] = urllib.parse.quote(headers['Destination'])
return self.conn.make_request('COPY', self.path, hdrs=headers,
parms=parms) == 201
diff --git a/test/functional/tests.py b/test/functional/tests.py
index 7fa3ceb45..dd92827a4 100644
--- a/test/functional/tests.py
+++ b/test/functional/tests.py
@@ -22,9 +22,9 @@ import json
import locale
import random
import six
+from six.moves import urllib
import time
import unittest
-import urllib
import uuid
from copy import deepcopy
import eventlet
@@ -281,7 +281,7 @@ class TestAccount(Base):
inserted_html = '<b>Hello World'
hax = 'AUTH_haxx"\nContent-Length: %d\n\n%s' % (len(inserted_html),
inserted_html)
- quoted_hax = urllib.quote(hax)
+ quoted_hax = urllib.parse.quote(hax)
conn.connection.request('GET', '/v1/' + quoted_hax, None, {})
resp = conn.connection.getresponse()
resp_headers = dict(resp.getheaders())
@@ -3152,7 +3152,7 @@ class TestTempurl(Base):
def tempurl_sig(self, method, expires, path, key):
return hmac.new(
key,
- '%s\n%s\n%s' % (method, expires, urllib.unquote(path)),
+ '%s\n%s\n%s' % (method, expires, urllib.parse.unquote(path)),
hashlib.sha1).hexdigest()
def test_GET(self):
@@ -3441,7 +3441,7 @@ class TestContainerTempurl(Base):
def tempurl_sig(self, method, expires, path, key):
return hmac.new(
key,
- '%s\n%s\n%s' % (method, expires, urllib.unquote(path)),
+ '%s\n%s\n%s' % (method, expires, urllib.parse.unquote(path)),
hashlib.sha1).hexdigest()
def test_GET(self):
@@ -3706,7 +3706,7 @@ class TestSloTempurl(Base):
def tempurl_sig(self, method, expires, path, key):
return hmac.new(
key,
- '%s\n%s\n%s' % (method, expires, urllib.unquote(path)),
+ '%s\n%s\n%s' % (method, expires, urllib.parse.unquote(path)),
hashlib.sha1).hexdigest()
def test_GET(self):
diff --git a/test/probe/brain.py b/test/probe/brain.py
index 9ec907c0a..ea5c2cc5e 100644
--- a/test/probe/brain.py
+++ b/test/probe/brain.py
@@ -16,10 +16,10 @@ import sys
import itertools
import uuid
from optparse import OptionParser
-from urlparse import urlparse
import random
import six
+from six.moves.urllib.parse import urlparse
from swift.common.manager import Manager
from swift.common import utils, ring
diff --git a/test/probe/test_account_get_fake_responses_match.py b/test/probe/test_account_get_fake_responses_match.py
index 46ddb16de..bd159300e 100755
--- a/test/probe/test_account_get_fake_responses_match.py
+++ b/test/probe/test_account_get_fake_responses_match.py
@@ -18,9 +18,9 @@ import re
import unittest
from six.moves import http_client
+from six.moves.urllib.parse import urlparse
from swiftclient import get_auth
from test.probe.common import ReplProbeTest
-from urlparse import urlparse
class TestAccountGetFakeResponsesMatch(ReplProbeTest):
diff --git a/test/probe/test_container_sync.py b/test/probe/test_container_sync.py
index 19ba23118..4288dd464 100644
--- a/test/probe/test_container_sync.py
+++ b/test/probe/test_container_sync.py
@@ -13,11 +13,11 @@
# limitations under the License.
import uuid
-from urlparse import urlparse
import random
from nose import SkipTest
import unittest
+from six.moves.urllib.parse import urlparse
from swiftclient import client
from swift.common.manager import Manager
diff --git a/test/unit/cli/test_recon.py b/test/unit/cli/test_recon.py
index 3b0d11f88..6fef1d333 100644
--- a/test/unit/cli/test_recon.py
+++ b/test/unit/cli/test_recon.py
@@ -23,10 +23,10 @@ import string
import tempfile
import time
import unittest
-import urlparse
from eventlet.green import urllib2
from six import StringIO
+from six.moves import urllib
from swift.cli import recon
from swift.common import utils
@@ -342,7 +342,7 @@ class TestReconCommands(unittest.TestCase):
def mock_responses(self, resps):
def fake_urlopen(url, timeout):
- scheme, netloc, path, _, _, _ = urlparse.urlparse(url)
+ scheme, netloc, path, _, _, _ = urllib.parse.urlparse(url)
self.assertEqual(scheme, 'http') # can't handle anything else
self.assertTrue(path.startswith('/recon/'))
diff --git a/test/unit/common/middleware/test_bulk.py b/test/unit/common/middleware/test_bulk.py
index c961b04e1..a3982887c 100644
--- a/test/unit/common/middleware/test_bulk.py
+++ b/test/unit/common/middleware/test_bulk.py
@@ -15,10 +15,10 @@
# limitations under the License.
import numbers
+from six.moves import urllib
import unittest
import os
import tarfile
-import urllib
import zlib
import mock
import six
@@ -763,10 +763,11 @@ class TestDelete(unittest.TestCase):
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEquals(len(resp_data['Errors']), 2)
- self.assertEquals(
- resp_data['Errors'],
- [[urllib.quote('c/ objbadutf8'), '412 Precondition Failed'],
- [urllib.quote('/c/f\xdebadutf8'), '412 Precondition Failed']])
+ self.assertEquals(resp_data['Errors'],
+ [[urllib.parse.quote('c/ objbadutf8'),
+ '412 Precondition Failed'],
+ [urllib.parse.quote('/c/f\xdebadutf8'),
+ '412 Precondition Failed']])
def test_bulk_delete_no_body(self):
req = Request.blank('/unauth/AUTH_acc/')
diff --git a/test/unit/common/middleware/test_proxy_logging.py b/test/unit/common/middleware/test_proxy_logging.py
index c24f1c48b..d7d22aaae 100644
--- a/test/unit/common/middleware/test_proxy_logging.py
+++ b/test/unit/common/middleware/test_proxy_logging.py
@@ -14,11 +14,11 @@
# limitations under the License.
import unittest
-from urllib import unquote
from logging.handlers import SysLogHandler
import mock
from six import BytesIO
+from six.moves.urllib.parse import unquote
from test.unit import FakeLogger
from swift.common.utils import get_logger, split_path
diff --git a/test/unit/common/test_direct_client.py b/test/unit/common/test_direct_client.py
index 38accd014..fe89f5769 100644
--- a/test/unit/common/test_direct_client.py
+++ b/test/unit/common/test_direct_client.py
@@ -16,13 +16,13 @@
import json
import unittest
import os
-import urllib
from contextlib import contextmanager
from hashlib import md5
import time
import mock
import six
+from six.moves import urllib
from swift.common import direct_client
from swift.common.exceptions import ClientException
@@ -97,13 +97,13 @@ class TestDirectClient(unittest.TestCase):
self.account = u'\u062a account'
self.container = u'\u062a container'
self.obj = u'\u062a obj/name'
- self.account_path = '/sda/0/%s' % urllib.quote(
+ self.account_path = '/sda/0/%s' % urllib.parse.quote(
self.account.encode('utf-8'))
self.container_path = '/sda/0/%s/%s' % tuple(
- urllib.quote(p.encode('utf-8')) for p in (
+ urllib.parse.quote(p.encode('utf-8')) for p in (
self.account, self.container))
self.obj_path = '/sda/0/%s/%s/%s' % tuple(
- urllib.quote(p.encode('utf-8')) for p in (
+ urllib.parse.quote(p.encode('utf-8')) for p in (
self.account, self.container, self.obj))
self.user_agent = 'direct-client %s' % os.getpid()
diff --git a/test/unit/common/test_internal_client.py b/test/unit/common/test_internal_client.py
index 3c817fbc9..66c9d04a2 100644
--- a/test/unit/common/test_internal_client.py
+++ b/test/unit/common/test_internal_client.py
@@ -16,7 +16,6 @@
import json
import mock
import unittest
-from urllib import quote
import zlib
from textwrap import dedent
import os
@@ -24,6 +23,7 @@ import os
import six
from six import StringIO
from six.moves import range
+from six.moves.urllib.parse import quote
from test.unit import FakeLogger
from eventlet.green import urllib2
from swift.common import internal_client
diff --git a/test/unit/common/test_swob.py b/test/unit/common/test_swob.py
index 6257d63c8..f57eabdf1 100644
--- a/test/unit/common/test_swob.py
+++ b/test/unit/common/test_swob.py
@@ -19,9 +19,9 @@ import datetime
import unittest
import re
import time
-from urllib import quote
from six import BytesIO
+from six.moves.urllib.parse import quote
import swift.common.swob
from swift.common import utils, exceptions
diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py
index 1e786e273..e2b3a8c3a 100644
--- a/test/unit/common/test_wsgi.py
+++ b/test/unit/common/test_wsgi.py
@@ -24,11 +24,11 @@ import os
from textwrap import dedent
from contextlib import nested
from collections import defaultdict
-from urllib import quote
from eventlet import listen
from six import BytesIO
from six import StringIO
+from six.moves.urllib.parse import quote
import mock
diff --git a/test/unit/container/test_reconciler.py b/test/unit/container/test_reconciler.py
index 1b4122760..e96213614 100644
--- a/test/unit/container/test_reconciler.py
+++ b/test/unit/container/test_reconciler.py
@@ -17,7 +17,6 @@ import mock
import operator
import time
import unittest
-import urllib
import socket
import os
import errno
@@ -26,6 +25,7 @@ import random
from collections import defaultdict
from datetime import datetime
+from six.moves import urllib
from swift.container import reconciler
from swift.container.server import gen_resp_headers
from swift.common.direct_client import ClientException
@@ -153,7 +153,7 @@ class FakeInternalClient(reconciler.InternalClient):
obj_name = container_listing_data[-1]['name']
# client should quote and encode marker
end_qry_string = '?format=json&marker=%s&end_marker=' % (
- urllib.quote(obj_name.encode('utf-8')))
+ urllib.parse.quote(obj_name.encode('utf-8')))
self.app.register('GET', container_path + end_qry_string,
swob.HTTPOk, container_headers,
json.dumps([]))
@@ -170,7 +170,7 @@ class FakeInternalClient(reconciler.InternalClient):
swob.HTTPOk, account_headers,
json.dumps(account_listing_data))
end_qry_string = '?format=json&marker=%s&end_marker=' % (
- urllib.quote(account_listing_data[-1]['name']))
+ urllib.parse.quote(account_listing_data[-1]['name']))
self.app.register('GET', account_path + end_qry_string,
swob.HTTPOk, account_headers,
json.dumps([]))
@@ -685,7 +685,7 @@ class TestReconcilerUtils(unittest.TestCase):
def listing_qs(marker):
return "?format=json&marker=%s&end_marker=" % \
- urllib.quote(marker.encode('utf-8'))
+ urllib.parse.quote(marker.encode('utf-8'))
class TestReconciler(unittest.TestCase):
diff --git a/test/unit/obj/test_expirer.py b/test/unit/obj/test_expirer.py
index 0aa3091ef..17fddf174 100644
--- a/test/unit/obj/test_expirer.py
+++ b/test/unit/obj/test_expirer.py
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import urllib
from time import time
from unittest import main, TestCase
from test.unit import FakeRing, mocked_http_conn, debug_logger
@@ -23,6 +22,7 @@ from shutil import rmtree
import mock
import six
+from six.moves import urllib
from swift.common import internal_client, utils
from swift.obj import expirer
@@ -746,7 +746,7 @@ class TestObjectExpirer(TestCase):
x.delete_actual_object(name, timestamp)
self.assertEqual(x.swift.make_request.call_count, 1)
self.assertEqual(x.swift.make_request.call_args[0][1],
- '/v1/' + urllib.quote(name))
+ '/v1/' + urllib.parse.quote(name))
def test_pop_queue(self):
class InternalClient(object):
diff --git a/test/unit/obj/test_ssync_sender.py b/test/unit/obj/test_ssync_sender.py
index e9edafd4f..8d049fadc 100644
--- a/test/unit/obj/test_ssync_sender.py
+++ b/test/unit/obj/test_ssync_sender.py
@@ -20,12 +20,12 @@ import shutil
import tempfile
import time
import unittest
-import urllib
import eventlet
import itertools
import mock
import six
+from six.moves import urllib
from swift.common import exceptions, utils
from swift.common.storage_policy import POLICIES
@@ -2368,7 +2368,8 @@ class TestSsyncReplication(TestBaseSsync):
def _legacy_check_missing(self, line):
# reproduces behavior of 'legacy' ssync receiver missing_checks()
parts = line.split()
- object_hash, timestamp = [urllib.unquote(v) for v in parts[:2]]
+ object_hash = urllib.parse.unquote(parts[0])
+ timestamp = urllib.parse.unquote(parts[1])
want = False
try:
df = self.diskfile_mgr.get_diskfile_from_hash(
@@ -2386,7 +2387,7 @@ class TestSsyncReplication(TestBaseSsync):
else:
want = df.timestamp < timestamp
if want:
- return urllib.quote(object_hash)
+ return urllib.parse.quote(object_hash)
return None
# run the sync protocol...
diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py
index 1c8d346dd..baa876237 100644
--- a/test/unit/proxy/test_server.py
+++ b/test/unit/proxy/test_server.py
@@ -28,7 +28,6 @@ from shutil import rmtree
import gc
import time
from textwrap import dedent
-from urllib import quote
from hashlib import md5
from pyeclib.ec_iface import ECDriverError
from tempfile import mkdtemp, NamedTemporaryFile
@@ -46,6 +45,8 @@ from eventlet.green import httplib
from six import BytesIO
from six import StringIO
from six.moves import range
+from six.moves.urllib.parse import quote
+
from swift.common.utils import hash_path, json, storage_directory, \
parse_content_type, parse_mime_headers, \
iter_multipart_mime_documents, public
diff --git a/test/unit/proxy/test_sysmeta.py b/test/unit/proxy/test_sysmeta.py
index 98e9a76e9..3b3f8ddfd 100644
--- a/test/unit/proxy/test_sysmeta.py
+++ b/test/unit/proxy/test_sysmeta.py
@@ -12,10 +12,12 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+from six.moves.urllib.parse import quote
+
import unittest
import os
from tempfile import mkdtemp
-from urllib import quote
import shutil
from swift.common.storage_policy import StoragePolicy
from swift.common.swob import Request