Merge "py3: Replace urllib imports with six.moves.urllib"

This commit is contained in:
Jenkins 2015-10-10 07:20:26 +00:00 committed by Gerrit Code Review
commit 6b854bd908
42 changed files with 96 additions and 79 deletions

View File

@ -16,7 +16,6 @@
import os import os
import sys import sys
from urllib import quote
from hashlib import md5 from hashlib import md5
import getopt import getopt
from itertools import chain from itertools import chain
@ -24,6 +23,7 @@ from itertools import chain
import simplejson import simplejson
from eventlet.greenpool import GreenPool from eventlet.greenpool import GreenPool
from eventlet.event import Event from eventlet.event import Event
from six.moves.urllib.parse import quote
from swift.common.ring import Ring from swift.common.ring import Ring
from swift.common.utils import split_path from swift.common.utils import split_path

View File

@ -14,9 +14,10 @@ from __future__ import print_function
import itertools import itertools
import os import os
import sqlite3 import sqlite3
import urllib
from hashlib import md5 from hashlib import md5
from six.moves import urllib
from swift.common.utils import hash_path, storage_directory, \ from swift.common.utils import hash_path, storage_directory, \
Timestamp Timestamp
from swift.common.ring import Ring 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: for node in primary_nodes:
cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \ cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
% (node['ip'], node['port'], node['device'], part, % (node['ip'], node['port'], node['device'], part,
urllib.quote(target)) urllib.parse.quote(target))
if policy_index is not None: if policy_index is not None:
cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index', cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index',
policy_index) policy_index)
@ -108,7 +109,7 @@ def print_ring_locations(ring, datadir, account, container=None, obj=None,
for node in handoff_nodes: for node in handoff_nodes:
cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \ cmd = 'curl -I -XHEAD "http://%s:%s/%s/%s/%s"' \
% (node['ip'], node['port'], node['device'], part, % (node['ip'], node['port'], node['device'], part,
urllib.quote(target)) urllib.parse.quote(target))
if policy_index is not None: if policy_index is not None:
cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index', cmd += ' -H "%s: %s"' % ('X-Backend-Storage-Policy-Index',
policy_index) policy_index)

View File

@ -19,9 +19,9 @@
from __future__ import print_function from __future__ import print_function
from eventlet.green import urllib2 from eventlet.green import urllib2
from six.moves.urllib.parse import urlparse
from swift.common.utils import SWIFT_CONF_FILE from swift.common.utils import SWIFT_CONF_FILE
from swift.common.ring import Ring from swift.common.ring import Ring
from urlparse import urlparse
from hashlib import md5 from hashlib import md5
import eventlet import eventlet
import json import json

View File

@ -28,7 +28,6 @@ BufferedHTTPResponse.
from swift import gettext_ as _ from swift import gettext_ as _
from swift.common import constraints from swift.common import constraints
from urllib import quote
import logging import logging
import time import time
import socket import socket
@ -36,6 +35,7 @@ import socket
import eventlet import eventlet
from eventlet.green.httplib import CONTINUE, HTTPConnection, HTTPMessage, \ from eventlet.green.httplib import CONTINUE, HTTPConnection, HTTPMessage, \
HTTPResponse, HTTPSConnection, _UNKNOWN HTTPResponse, HTTPSConnection, _UNKNOWN
from six.moves.urllib.parse import quote
import six import six
httplib = eventlet.import_patched('httplib') httplib = eventlet.import_patched('httplib')

View File

@ -15,12 +15,12 @@
import functools import functools
import os import os
import urllib
import time import time
from urllib import unquote
import six import six
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError 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 import utils, exceptions
from swift.common.swob import HTTPBadRequest, HTTPLengthRequired, \ from swift.common.swob import HTTPBadRequest, HTTPLengthRequired, \
@ -246,7 +246,7 @@ def check_mount(root, drive):
:param drive: drive name to be checked :param drive: drive name to be checked
:returns: True if it is a valid mounted device, False otherwise :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 return False
path = os.path.join(root, drive) path = os.path.join(root, drive)
return utils.ismount(path) return utils.ismount(path)

View File

@ -17,12 +17,12 @@ from eventlet import sleep, Timeout
from eventlet.green import httplib, socket, urllib2 from eventlet.green import httplib, socket, urllib2
import json import json
from six.moves import range from six.moves import range
from six.moves import urllib
import struct import struct
from sys import exc_info from sys import exc_info
import zlib import zlib
from swift import gettext_ as _ from swift import gettext_ as _
from time import gmtime, strftime, time from time import gmtime, strftime, time
import urlparse
from zlib import compressobj from zlib import compressobj
from swift.common.utils import quote from swift.common.utils import quote
@ -760,7 +760,7 @@ class SimpleClient(object):
req = urllib2.Request(url, headers=headers, data=contents) req = urllib2.Request(url, headers=headers, data=contents)
if proxy: if proxy:
proxy = urlparse.urlparse(proxy) proxy = urllib.parse.urlparse(proxy)
req.set_proxy(proxy.netloc, proxy.scheme) req.set_proxy(proxy.netloc, proxy.scheme)
req.get_method = lambda: method req.get_method = lambda: method
conn = urllib2.urlopen(req, timeout=timeout) conn = urllib2.urlopen(req, timeout=timeout)

View File

@ -13,8 +13,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from six.moves.urllib.parse import quote, unquote
import tarfile import tarfile
from urllib import quote, unquote
from xml.sax import saxutils from xml.sax import saxutils
from time import time from time import time
from eventlet import sleep from eventlet import sleep

View File

@ -17,6 +17,7 @@ import os
import six import six
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
from six.moves.urllib.parse import unquote
from hashlib import md5 from hashlib import md5
from swift.common import constraints from swift.common import constraints
@ -29,7 +30,6 @@ from swift.common.utils import get_logger, json, \
closing_if_possible closing_if_possible
from swift.common.request_helpers import SegmentedIterable from swift.common.request_helpers import SegmentedIterable
from swift.common.wsgi import WSGIContext, make_subrequest from swift.common.wsgi import WSGIContext, make_subrequest
from urllib import unquote
class GetContext(WSGIContext): class GetContext(WSGIContext):

View File

@ -115,8 +115,8 @@ __all__ = ['FormPost', 'filter_factory', 'READ_CHUNK_SIZE', 'MAX_VALUE_LENGTH']
import hmac import hmac
from hashlib import sha1 from hashlib import sha1
from time import time from time import time
from urllib import quote
from six.moves.urllib.parse import quote
from swift.common.exceptions import MimeInvalid from swift.common.exceptions import MimeInvalid
from swift.common.middleware.tempurl import get_tempurl_keys_from_metadata from swift.common.middleware.tempurl import get_tempurl_keys_from_metadata
from swift.common.utils import streq_const_time, register_swift_info, \ from swift.common.utils import streq_const_time, register_swift_info, \

View File

@ -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). 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.ring import Ring
from swift.common.utils import json, get_logger, split_path from swift.common.utils import json, get_logger, split_path

View File

@ -40,9 +40,10 @@ The filter returns HTTPBadRequest if path is invalid.
@author: eamonn-otoole @author: eamonn-otoole
''' '''
from six.moves.urllib.parse import unquote
import re import re
from swift.common.utils import get_logger from swift.common.utils import get_logger
from urllib2 import unquote
from swift.common.swob import Request, HTTPBadRequest from swift.common.swob import Request, HTTPBadRequest

View File

@ -73,8 +73,8 @@ bandwidth usage will want to only sum up logs with no swift.source.
import sys import sys
import time import time
from urllib import quote, unquote
from six.moves.urllib.parse import quote, unquote
from swift.common.swob import Request from swift.common.swob import Request
from swift.common.utils import (get_logger, get_remote_client, from swift.common.utils import (get_logger, get_remote_client,
get_valid_utf8_str, config_true_value, get_valid_utf8_str, config_true_value,

View File

@ -17,13 +17,13 @@ from __future__ import print_function
from time import time from time import time
from traceback import format_exc from traceback import format_exc
from urllib import unquote
from uuid import uuid4 from uuid import uuid4
from hashlib import sha1 from hashlib import sha1
import hmac import hmac
import base64 import base64
from eventlet import Timeout from eventlet import Timeout
from six.moves.urllib.parse import unquote
from swift.common.swob import Response, Request from swift.common.swob import Response, Request
from swift.common.swob import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \ from swift.common.swob import HTTPBadRequest, HTTPForbidden, HTTPNotFound, \
HTTPUnauthorized HTTPUnauthorized

View File

@ -118,8 +118,9 @@ __all__ = ['TempURL', 'filter_factory',
from os.path import basename from os.path import basename
from time import time 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.proxy.controllers.base import get_account_info, get_container_info
from swift.common.swob import HeaderKeyDict, HTTPUnauthorized, HTTPBadRequest from swift.common.swob import HeaderKeyDict, HTTPUnauthorized, HTTPBadRequest

View File

@ -114,8 +114,8 @@ Disable versioning from a container (x is any value except empty)::
""" """
import six import six
from six.moves.urllib.parse import quote, unquote
import time import time
from urllib import quote, unquote
from swift.common.utils import get_logger, Timestamp, json, \ from swift.common.utils import get_logger, Timestamp, json, \
register_swift_info, config_true_value register_swift_info, config_true_value
from swift.common.request_helpers import get_sys_meta_prefix from swift.common.request_helpers import get_sys_meta_prefix

View File

@ -24,9 +24,9 @@ import hashlib
import itertools import itertools
import sys import sys
import time import time
from urllib import unquote
import six import six
from six.moves.urllib.parse import unquote
from swift import gettext_ as _ from swift import gettext_ as _
from swift.common.storage_policy import POLICIES from swift.common.storage_policy import POLICIES

View File

@ -33,7 +33,7 @@ from paste.deploy import loadwsgi
from eventlet.green import socket, ssl, os as green_os from eventlet.green import socket, ssl, os as green_os
from six import BytesIO from six import BytesIO
from six import StringIO from six import StringIO
from urllib import unquote from six.moves.urllib.parse import unquote
from swift.common import utils, constraints from swift.common import utils, constraints
from swift.common.storage_policy import BindPortsCache from swift.common.storage_policy import BindPortsCache

View File

@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import urllib from six.moves import urllib
from random import random from random import random
from time import time from time import time
from os.path import join from os.path import join
@ -290,7 +291,7 @@ class ObjectExpirer(Daemon):
:param timestamp: The timestamp the X-Delete-At value must match to :param timestamp: The timestamp the X-Delete-At value must match to
perform the actual delete. 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, self.swift.make_request('DELETE', path,
{'X-If-Delete-At': str(timestamp)}, {'X-If-Delete-At': str(timestamp)},
(2, HTTP_PRECONDITION_FAILED)) (2, HTTP_PRECONDITION_FAILED))

View File

@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import urllib
import eventlet import eventlet
import eventlet.wsgi import eventlet.wsgi
import eventlet.greenio import eventlet.greenio
from six.moves import urllib
from swift.common import exceptions from swift.common import exceptions
from swift.common import http from swift.common import http
@ -38,11 +38,12 @@ def decode_missing(line):
""" """
result = {} result = {}
parts = line.split() 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) result['ts_data'] = result['ts_meta'] = Timestamp(t_data)
if len(parts) > 2: if len(parts) > 2:
# allow for a comma separated list of k:v pairs to future-proof # 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]: for item in [subpart for subpart in subparts if ':' in subpart]:
k, v = item.split(':') k, v = item.split(':')
if k == 'm': if k == 'm':
@ -78,7 +79,7 @@ def encode_wanted(remote, local):
# this is the inverse of _decode_wanted's key_map # this is the inverse of _decode_wanted's key_map
key_map = dict(data='d', meta='m') key_map = dict(data='d', meta='m')
parts = ''.join(v for k, v in sorted(key_map.items()) if want.get(k)) 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 return None

View File

@ -13,7 +13,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import urllib from six.moves import urllib
from itertools import ifilter from itertools import ifilter
from swift.common import bufferedhttp from swift.common import bufferedhttp
from swift.common import exceptions 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 The decoder for this line is
:py:func:`~swift.obj.ssync_receiver.decode_missing` :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: if ts_meta and ts_meta != ts_data:
delta = ts_meta.raw - ts_data.raw delta = ts_meta.raw - ts_data.raw
msg = '%s m:%x' % (msg, delta) msg = '%s m:%x' % (msg, delta)
@ -318,14 +321,14 @@ class Sender(object):
msg = ':UPDATES: START\r\n' msg = ':UPDATES: START\r\n'
self.connection.send('%x\r\n%s\r\n' % (len(msg), msg)) self.connection.send('%x\r\n%s\r\n' % (len(msg), msg))
for object_hash, want in self.send_map.items(): for object_hash, want in self.send_map.items():
object_hash = urllib.unquote(object_hash) object_hash = urllib.parse.unquote(object_hash)
try: try:
df = self.df_mgr.get_diskfile_from_hash( df = self.df_mgr.get_diskfile_from_hash(
self.job['device'], self.job['partition'], object_hash, self.job['device'], self.job['partition'], object_hash,
self.job['policy'], frag_index=self.job.get('frag_index')) self.job['policy'], frag_index=self.job.get('frag_index'))
except exceptions.DiskFileNotExist: except exceptions.DiskFileNotExist:
continue continue
url_path = urllib.quote( url_path = urllib.parse.quote(
'/%s/%s/%s' % (df.account, df.container, df.obj)) '/%s/%s/%s' % (df.account, df.container, df.obj))
try: try:
df.open() df.open()

View File

@ -13,8 +13,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from six.moves.urllib.parse import unquote
from swift import gettext_ as _ from swift import gettext_ as _
from urllib import unquote
from swift.account.utils import account_listing_response from swift.account.utils import account_listing_response
from swift.common.request_helpers import get_listing_content_type from swift.common.request_helpers import get_listing_content_type

View File

@ -24,6 +24,8 @@
# These shenanigans are to ensure all related objects can be garbage # These shenanigans are to ensure all related objects can be garbage
# collected. We've seen objects hang around forever otherwise. # collected. We've seen objects hang around forever otherwise.
from six.moves.urllib.parse import quote
import os import os
import time import time
import functools import functools
@ -32,7 +34,6 @@ import itertools
import operator import operator
from sys import exc_info from sys import exc_info
from swift import gettext_ as _ from swift import gettext_ as _
from urllib import quote
from eventlet import sleep from eventlet import sleep
from eventlet.timeout import Timeout from eventlet.timeout import Timeout

View File

@ -14,9 +14,9 @@
# limitations under the License. # limitations under the License.
from swift import gettext_ as _ from swift import gettext_ as _
from urllib import unquote
import time import time
from six.moves.urllib.parse import unquote
from swift.common.utils import public, csv_append, Timestamp from swift.common.utils import public, csv_append, Timestamp
from swift.common.constraints import check_metadata from swift.common.constraints import check_metadata
from swift.common import constraints from swift.common import constraints

View File

@ -24,6 +24,8 @@
# These shenanigans are to ensure all related objects can be garbage # These shenanigans are to ensure all related objects can be garbage
# collected. We've seen objects hang around forever otherwise. # collected. We've seen objects hang around forever otherwise.
from six.moves.urllib.parse import unquote, quote
import collections import collections
import itertools import itertools
import mimetypes import mimetypes
@ -32,7 +34,6 @@ import math
import random import random
from hashlib import md5 from hashlib import md5
from swift import gettext_ as _ from swift import gettext_ as _
from urllib import unquote, quote
from greenlet import GreenletExit from greenlet import GreenletExit
from eventlet import GreenPile from eventlet import GreenPile

View File

@ -16,6 +16,7 @@
from __future__ import print_function from __future__ import print_function
import mock import mock
import os import os
from six.moves.urllib.parse import urlparse
import sys import sys
import pickle import pickle
import socket import socket
@ -26,7 +27,6 @@ import functools
import random import random
from time import time, sleep from time import time, sleep
from urlparse import urlparse
from nose import SkipTest from nose import SkipTest
from contextlib import closing from contextlib import closing
from gzip import GzipFile from gzip import GzipFile

View File

@ -18,7 +18,6 @@ import os
import random import random
import socket import socket
import time import time
import urllib
import simplejson as json import simplejson as json
from nose import SkipTest from nose import SkipTest
@ -26,6 +25,7 @@ from xml.dom import minidom
import six import six
from six.moves import http_client from six.moves import http_client
from six.moves import urllib
from swiftclient import get_auth from swiftclient import get_auth
from swift.common import constraints from swift.common import constraints
@ -220,7 +220,7 @@ class Connection(object):
return '/' + self.storage_url.split('/')[1] return '/' + self.storage_url.split('/')[1]
if path: if path:
quote = urllib.quote quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_path_quote'): if cfg.get('no_quote') or cfg.get('no_path_quote'):
quote = lambda x: x quote = lambda x: x
return '%s/%s' % (self.storage_url, return '%s/%s' % (self.storage_url,
@ -260,7 +260,7 @@ class Connection(object):
path = self.make_path(path, cfg=cfg) path = self.make_path(path, cfg=cfg)
headers = self.make_headers(hdrs, cfg=cfg) headers = self.make_headers(hdrs, cfg=cfg)
if isinstance(parms, dict) and parms: if isinstance(parms, dict) and parms:
quote = urllib.quote quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_parms_quote'): if cfg.get('no_quote') or cfg.get('no_parms_quote'):
quote = lambda x: x quote = lambda x: x
query_args = ['%s=%s' % (quote(x), quote(str(y))) query_args = ['%s=%s' % (quote(x), quote(str(y)))
@ -328,7 +328,7 @@ class Connection(object):
headers.pop('Content-Length', None) headers.pop('Content-Length', None)
if isinstance(parms, dict) and parms: if isinstance(parms, dict) and parms:
quote = urllib.quote quote = urllib.parse.quote
if cfg.get('no_quote') or cfg.get('no_parms_quote'): if cfg.get('no_quote') or cfg.get('no_parms_quote'):
quote = lambda x: x quote = lambda x: x
query_args = ['%s=%s' % (quote(x), quote(str(y))) query_args = ['%s=%s' % (quote(x), quote(str(y)))
@ -698,7 +698,7 @@ class File(Base):
headers.update(hdrs) headers.update(hdrs)
if 'Destination' in headers: 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, return self.conn.make_request('COPY', self.path, hdrs=headers,
parms=parms) == 201 parms=parms) == 201
@ -722,9 +722,9 @@ class File(Base):
if 'Destination-Account' in headers: if 'Destination-Account' in headers:
headers['Destination-Account'] = \ headers['Destination-Account'] = \
urllib.quote(headers['Destination-Account']) urllib.parse.quote(headers['Destination-Account'])
if 'Destination' in headers: 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, return self.conn.make_request('COPY', self.path, hdrs=headers,
parms=parms) == 201 parms=parms) == 201

View File

@ -22,9 +22,9 @@ import json
import locale import locale
import random import random
import six import six
from six.moves import urllib
import time import time
import unittest import unittest
import urllib
import uuid import uuid
from copy import deepcopy from copy import deepcopy
import eventlet import eventlet
@ -281,7 +281,7 @@ class TestAccount(Base):
inserted_html = '<b>Hello World' inserted_html = '<b>Hello World'
hax = 'AUTH_haxx"\nContent-Length: %d\n\n%s' % (len(inserted_html), hax = 'AUTH_haxx"\nContent-Length: %d\n\n%s' % (len(inserted_html),
inserted_html) inserted_html)
quoted_hax = urllib.quote(hax) quoted_hax = urllib.parse.quote(hax)
conn.connection.request('GET', '/v1/' + quoted_hax, None, {}) conn.connection.request('GET', '/v1/' + quoted_hax, None, {})
resp = conn.connection.getresponse() resp = conn.connection.getresponse()
resp_headers = dict(resp.getheaders()) resp_headers = dict(resp.getheaders())
@ -3152,7 +3152,7 @@ class TestTempurl(Base):
def tempurl_sig(self, method, expires, path, key): def tempurl_sig(self, method, expires, path, key):
return hmac.new( return hmac.new(
key, 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() hashlib.sha1).hexdigest()
def test_GET(self): def test_GET(self):
@ -3441,7 +3441,7 @@ class TestContainerTempurl(Base):
def tempurl_sig(self, method, expires, path, key): def tempurl_sig(self, method, expires, path, key):
return hmac.new( return hmac.new(
key, 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() hashlib.sha1).hexdigest()
def test_GET(self): def test_GET(self):
@ -3706,7 +3706,7 @@ class TestSloTempurl(Base):
def tempurl_sig(self, method, expires, path, key): def tempurl_sig(self, method, expires, path, key):
return hmac.new( return hmac.new(
key, 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() hashlib.sha1).hexdigest()
def test_GET(self): def test_GET(self):

View File

@ -16,10 +16,10 @@ import sys
import itertools import itertools
import uuid import uuid
from optparse import OptionParser from optparse import OptionParser
from urlparse import urlparse
import random import random
import six import six
from six.moves.urllib.parse import urlparse
from swift.common.manager import Manager from swift.common.manager import Manager
from swift.common import utils, ring from swift.common import utils, ring

View File

@ -18,9 +18,9 @@ import re
import unittest import unittest
from six.moves import http_client from six.moves import http_client
from six.moves.urllib.parse import urlparse
from swiftclient import get_auth from swiftclient import get_auth
from test.probe.common import ReplProbeTest from test.probe.common import ReplProbeTest
from urlparse import urlparse
class TestAccountGetFakeResponsesMatch(ReplProbeTest): class TestAccountGetFakeResponsesMatch(ReplProbeTest):

View File

@ -13,11 +13,11 @@
# limitations under the License. # limitations under the License.
import uuid import uuid
from urlparse import urlparse
import random import random
from nose import SkipTest from nose import SkipTest
import unittest import unittest
from six.moves.urllib.parse import urlparse
from swiftclient import client from swiftclient import client
from swift.common.manager import Manager from swift.common.manager import Manager

View File

@ -23,10 +23,10 @@ import string
import tempfile import tempfile
import time import time
import unittest import unittest
import urlparse
from eventlet.green import urllib2 from eventlet.green import urllib2
from six import StringIO from six import StringIO
from six.moves import urllib
from swift.cli import recon from swift.cli import recon
from swift.common import utils from swift.common import utils
@ -342,7 +342,7 @@ class TestReconCommands(unittest.TestCase):
def mock_responses(self, resps): def mock_responses(self, resps):
def fake_urlopen(url, timeout): 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.assertEqual(scheme, 'http') # can't handle anything else
self.assertTrue(path.startswith('/recon/')) self.assertTrue(path.startswith('/recon/'))

View File

@ -15,10 +15,10 @@
# limitations under the License. # limitations under the License.
import numbers import numbers
from six.moves import urllib
import unittest import unittest
import os import os
import tarfile import tarfile
import urllib
import zlib import zlib
import mock import mock
import six import six
@ -763,10 +763,11 @@ class TestDelete(unittest.TestCase):
resp_data = utils.json.loads(resp_body) resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 1) self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEquals(len(resp_data['Errors']), 2) self.assertEquals(len(resp_data['Errors']), 2)
self.assertEquals( self.assertEquals(resp_data['Errors'],
resp_data['Errors'], [[urllib.parse.quote('c/ objbadutf8'),
[[urllib.quote('c/ objbadutf8'), '412 Precondition Failed'], '412 Precondition Failed'],
[urllib.quote('/c/f\xdebadutf8'), '412 Precondition Failed']]) [urllib.parse.quote('/c/f\xdebadutf8'),
'412 Precondition Failed']])
def test_bulk_delete_no_body(self): def test_bulk_delete_no_body(self):
req = Request.blank('/unauth/AUTH_acc/') req = Request.blank('/unauth/AUTH_acc/')

View File

@ -14,11 +14,11 @@
# limitations under the License. # limitations under the License.
import unittest import unittest
from urllib import unquote
from logging.handlers import SysLogHandler from logging.handlers import SysLogHandler
import mock import mock
from six import BytesIO from six import BytesIO
from six.moves.urllib.parse import unquote
from test.unit import FakeLogger from test.unit import FakeLogger
from swift.common.utils import get_logger, split_path from swift.common.utils import get_logger, split_path

View File

@ -16,13 +16,13 @@
import json import json
import unittest import unittest
import os import os
import urllib
from contextlib import contextmanager from contextlib import contextmanager
from hashlib import md5 from hashlib import md5
import time import time
import mock import mock
import six import six
from six.moves import urllib
from swift.common import direct_client from swift.common import direct_client
from swift.common.exceptions import ClientException from swift.common.exceptions import ClientException
@ -97,13 +97,13 @@ class TestDirectClient(unittest.TestCase):
self.account = u'\u062a account' self.account = u'\u062a account'
self.container = u'\u062a container' self.container = u'\u062a container'
self.obj = u'\u062a obj/name' 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.account.encode('utf-8'))
self.container_path = '/sda/0/%s/%s' % tuple( 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.account, self.container))
self.obj_path = '/sda/0/%s/%s/%s' % tuple( 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.account, self.container, self.obj))
self.user_agent = 'direct-client %s' % os.getpid() self.user_agent = 'direct-client %s' % os.getpid()

View File

@ -16,7 +16,6 @@
import json import json
import mock import mock
import unittest import unittest
from urllib import quote
import zlib import zlib
from textwrap import dedent from textwrap import dedent
import os import os
@ -24,6 +23,7 @@ import os
import six import six
from six import StringIO from six import StringIO
from six.moves import range from six.moves import range
from six.moves.urllib.parse import quote
from test.unit import FakeLogger from test.unit import FakeLogger
from eventlet.green import urllib2 from eventlet.green import urllib2
from swift.common import internal_client from swift.common import internal_client

View File

@ -19,9 +19,9 @@ import datetime
import unittest import unittest
import re import re
import time import time
from urllib import quote
from six import BytesIO from six import BytesIO
from six.moves.urllib.parse import quote
import swift.common.swob import swift.common.swob
from swift.common import utils, exceptions from swift.common import utils, exceptions

View File

@ -24,11 +24,11 @@ import os
from textwrap import dedent from textwrap import dedent
from contextlib import nested from contextlib import nested
from collections import defaultdict from collections import defaultdict
from urllib import quote
from eventlet import listen from eventlet import listen
from six import BytesIO from six import BytesIO
from six import StringIO from six import StringIO
from six.moves.urllib.parse import quote
import mock import mock

View File

@ -17,7 +17,6 @@ import mock
import operator import operator
import time import time
import unittest import unittest
import urllib
import socket import socket
import os import os
import errno import errno
@ -26,6 +25,7 @@ import random
from collections import defaultdict from collections import defaultdict
from datetime import datetime from datetime import datetime
from six.moves import urllib
from swift.container import reconciler from swift.container import reconciler
from swift.container.server import gen_resp_headers from swift.container.server import gen_resp_headers
from swift.common.direct_client import ClientException from swift.common.direct_client import ClientException
@ -153,7 +153,7 @@ class FakeInternalClient(reconciler.InternalClient):
obj_name = container_listing_data[-1]['name'] obj_name = container_listing_data[-1]['name']
# client should quote and encode marker # client should quote and encode marker
end_qry_string = '?format=json&marker=%s&end_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, self.app.register('GET', container_path + end_qry_string,
swob.HTTPOk, container_headers, swob.HTTPOk, container_headers,
json.dumps([])) json.dumps([]))
@ -170,7 +170,7 @@ class FakeInternalClient(reconciler.InternalClient):
swob.HTTPOk, account_headers, swob.HTTPOk, account_headers,
json.dumps(account_listing_data)) json.dumps(account_listing_data))
end_qry_string = '?format=json&marker=%s&end_marker=' % ( 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, self.app.register('GET', account_path + end_qry_string,
swob.HTTPOk, account_headers, swob.HTTPOk, account_headers,
json.dumps([])) json.dumps([]))
@ -685,7 +685,7 @@ class TestReconcilerUtils(unittest.TestCase):
def listing_qs(marker): def listing_qs(marker):
return "?format=json&marker=%s&end_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): class TestReconciler(unittest.TestCase):

View File

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import urllib
from time import time from time import time
from unittest import main, TestCase from unittest import main, TestCase
from test.unit import FakeRing, mocked_http_conn, debug_logger from test.unit import FakeRing, mocked_http_conn, debug_logger
@ -23,6 +22,7 @@ from shutil import rmtree
import mock import mock
import six import six
from six.moves import urllib
from swift.common import internal_client, utils from swift.common import internal_client, utils
from swift.obj import expirer from swift.obj import expirer
@ -746,7 +746,7 @@ class TestObjectExpirer(TestCase):
x.delete_actual_object(name, timestamp) x.delete_actual_object(name, timestamp)
self.assertEqual(x.swift.make_request.call_count, 1) self.assertEqual(x.swift.make_request.call_count, 1)
self.assertEqual(x.swift.make_request.call_args[0][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): def test_pop_queue(self):
class InternalClient(object): class InternalClient(object):

View File

@ -20,12 +20,12 @@ import shutil
import tempfile import tempfile
import time import time
import unittest import unittest
import urllib
import eventlet import eventlet
import itertools import itertools
import mock import mock
import six import six
from six.moves import urllib
from swift.common import exceptions, utils from swift.common import exceptions, utils
from swift.common.storage_policy import POLICIES from swift.common.storage_policy import POLICIES
@ -2368,7 +2368,8 @@ class TestSsyncReplication(TestBaseSsync):
def _legacy_check_missing(self, line): def _legacy_check_missing(self, line):
# reproduces behavior of 'legacy' ssync receiver missing_checks() # reproduces behavior of 'legacy' ssync receiver missing_checks()
parts = line.split() 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 want = False
try: try:
df = self.diskfile_mgr.get_diskfile_from_hash( df = self.diskfile_mgr.get_diskfile_from_hash(
@ -2386,7 +2387,7 @@ class TestSsyncReplication(TestBaseSsync):
else: else:
want = df.timestamp < timestamp want = df.timestamp < timestamp
if want: if want:
return urllib.quote(object_hash) return urllib.parse.quote(object_hash)
return None return None
# run the sync protocol... # run the sync protocol...

View File

@ -28,7 +28,6 @@ from shutil import rmtree
import gc import gc
import time import time
from textwrap import dedent from textwrap import dedent
from urllib import quote
from hashlib import md5 from hashlib import md5
from pyeclib.ec_iface import ECDriverError from pyeclib.ec_iface import ECDriverError
from tempfile import mkdtemp, NamedTemporaryFile from tempfile import mkdtemp, NamedTemporaryFile
@ -46,6 +45,8 @@ from eventlet.green import httplib
from six import BytesIO from six import BytesIO
from six import StringIO from six import StringIO
from six.moves import range from six.moves import range
from six.moves.urllib.parse import quote
from swift.common.utils import hash_path, json, storage_directory, \ from swift.common.utils import hash_path, json, storage_directory, \
parse_content_type, parse_mime_headers, \ parse_content_type, parse_mime_headers, \
iter_multipart_mime_documents, public iter_multipart_mime_documents, public

View File

@ -12,10 +12,12 @@
# implied. # implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from six.moves.urllib.parse import quote
import unittest import unittest
import os import os
from tempfile import mkdtemp from tempfile import mkdtemp
from urllib import quote
import shutil import shutil
from swift.common.storage_policy import StoragePolicy from swift.common.storage_policy import StoragePolicy
from swift.common.swob import Request from swift.common.swob import Request