Merge "Use six to fix imports on Python 3"

This commit is contained in:
Jenkins 2015-07-28 10:25:25 +00:00 committed by Gerrit Code Review
commit b87e32591d
15 changed files with 46 additions and 33 deletions

View File

@ -17,7 +17,8 @@ import os
import urllib
import time
from urllib import unquote
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
from swift.common import utils, exceptions
from swift.common.swob import HTTPBadRequest, HTTPLengthRequired, \

View File

@ -13,13 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import ConfigParser
import errno
import hashlib
import hmac
import os
import time
from six.moves import configparser
from swift import gettext_ as _
from swift.common.utils import get_valid_utf8_str
@ -61,9 +62,9 @@ class ContainerSyncRealms(object):
if mtime != self.conf_path_mtime:
self.conf_path_mtime = mtime
try:
conf = ConfigParser.SafeConfigParser()
conf = configparser.SafeConfigParser()
conf.read(self.conf_path)
except ConfigParser.ParsingError as err:
except configparser.ParsingError as err:
self.logger.error(
_('Could not load %r: %s'), self.conf_path, err)
else:
@ -72,11 +73,11 @@ class ContainerSyncRealms(object):
'DEFAULT', 'mtime_check_interval')
self.next_mtime_check = \
now + self.mtime_check_interval
except ConfigParser.NoOptionError:
except configparser.NoOptionError:
self.mtime_check_interval = 300
self.next_mtime_check = \
now + self.mtime_check_interval
except (ConfigParser.ParsingError, ValueError) as err:
except (configparser.ParsingError, ValueError) as err:
self.logger.error(
_('Error in %r with mtime_check_interval: %s'),
self.conf_path, err)

View File

@ -20,10 +20,10 @@ through the proxy.
import os
import socket
from httplib import HTTPException
from time import time
from eventlet import sleep, Timeout
from six.moves.http_client import HTTPException
from swift.common.bufferedhttp import http_connect
from swift.common.exceptions import ClientException

View File

@ -14,7 +14,9 @@
# limitations under the License.
import os
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
from hashlib import md5
from swift.common import constraints
from swift.common.exceptions import ListingIterError, SegmentError

View File

@ -14,7 +14,8 @@
# limitations under the License.
import os
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
from swift.common.memcached import (MemcacheRing, CONN_TIMEOUT, POOL_TIMEOUT,
IO_TIMEOUT, TRY_COUNT)

View File

@ -11,12 +11,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from ConfigParser import ConfigParser
import os
import string
import textwrap
import six
from six.moves.configparser import ConfigParser
from swift.common.utils import (
config_true_value, SWIFT_CONF_FILE, whataremyips)
from swift.common.ring import Ring, RingData

View File

@ -38,10 +38,8 @@ from urllib import quote as _quote
from contextlib import contextmanager, closing
import ctypes
import ctypes.util
from ConfigParser import ConfigParser, NoSectionError, NoOptionError, \
RawConfigParser
from optparse import OptionParser
from Queue import Queue, Empty
from tempfile import mkstemp, NamedTemporaryFile
try:
import simplejson as json
@ -64,6 +62,9 @@ import netifaces
import codecs
utf8_decoder = codecs.getdecoder('utf-8')
utf8_encoder = codecs.getencoder('utf-8')
from six.moves.configparser import ConfigParser, NoSectionError, \
NoOptionError, RawConfigParser
from six.moves.queue import Queue, Empty
from six.moves import range
from swift import gettext_ as _

View File

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import httplib
import mock
import os
import sys
@ -24,15 +23,19 @@ import eventlet
import eventlet.debug
import functools
import random
from ConfigParser import ConfigParser, NoSectionError
from time import time, sleep
from httplib import HTTPException
from urlparse import urlparse
from nose import SkipTest
from contextlib import closing
from gzip import GzipFile
from shutil import rmtree
from tempfile import mkdtemp
from six.moves.configparser import ConfigParser, NoSectionError
from six.moves import http_client
from six.moves.http_client import HTTPException
from swift.common.middleware.memcache import MemcacheMiddleware
from swift.common.storage_policy import parse_storage_policies, PolicyError
@ -53,7 +56,7 @@ from swift.container import server as container_server
from swift.obj import server as object_server, mem_server as mem_object_server
import swift.proxy.controllers.obj
httplib._MAXHEADERS = constraints.MAX_HEADER_COUNT
http_client._MAXHEADERS = constraints.MAX_HEADER_COUNT
DEBUG = True
# In order to get the proper blocking behavior of sockets without using

View File

@ -14,7 +14,6 @@
# limitations under the License.
import hashlib
import httplib
import os
import random
import socket
@ -22,11 +21,11 @@ import time
import urllib
import simplejson as json
from nose import SkipTest
from xml.dom import minidom
import six
from six.moves import http_client
from swiftclient import get_auth
from swift.common import constraints
@ -34,7 +33,7 @@ from swift.common.utils import config_true_value
from test import safe_repr
httplib._MAXHEADERS = constraints.MAX_HEADER_COUNT
http_client._MAXHEADERS = constraints.MAX_HEADER_COUNT
class AuthenticationFailed(Exception):
@ -166,10 +165,10 @@ class Connection(object):
x = storage_url.split('/')
if x[0] == 'http:':
self.conn_class = httplib.HTTPConnection
self.conn_class = http_client.HTTPConnection
self.storage_port = 80
elif x[0] == 'https:':
self.conn_class = httplib.HTTPSConnection
self.conn_class = http_client.HTTPSConnection
self.storage_port = 443
else:
raise ValueError('unexpected protocol %s' % (x[0]))
@ -283,7 +282,7 @@ class Connection(object):
try:
self.response = try_request()
except httplib.HTTPException as e:
except http_client.HTTPException as e:
fail_messages.append(safe_repr(e))
continue

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from httplib import HTTPConnection
import os
from subprocess import Popen, PIPE
import sys
@ -22,8 +22,9 @@ from collections import defaultdict
import unittest
from nose import SkipTest
from swiftclient import get_auth, head_account
from six.moves.http_client import HTTPConnection
from swiftclient import get_auth, head_account
from swift.obj.diskfile import get_data_dir
from swift.common.ring import Ring
from swift.common.utils import readconf, renamer

View File

@ -14,10 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import httplib
import re
import unittest
from six.moves import http_client
from swiftclient import get_auth
from test.probe.common import ReplProbeTest
from urlparse import urlparse
@ -49,7 +49,7 @@ class TestAccountGetFakeResponsesMatch(ReplProbeTest):
host, port = netloc.split(':')
port = int(port)
conn = httplib.HTTPConnection(host, port)
conn = http_client.HTTPConnection(host, port)
conn.request(method, self._account_path(account), headers=headers)
resp = conn.getresponse()
if resp.status // 100 != 2:

View File

@ -37,7 +37,8 @@ from swift.common import swob, utils
from swift.common.ring import Ring, RingData
from hashlib import md5
import logging.handlers
from httplib import HTTPException
from six.moves.http_client import HTTPException
from swift.common import storage_policy
from swift.common.storage_policy import StoragePolicy, ECStoragePolicy
import functools

View File

@ -16,9 +16,9 @@
import os
from textwrap import dedent
import unittest
from ConfigParser import NoSectionError, NoOptionError
import mock
from six.moves.configparser import NoSectionError, NoOptionError
from swift.common.middleware import memcache
from swift.common.memcached import MemcacheRing

View File

@ -14,10 +14,11 @@
""" Tests for swift.common.storage_policies """
import six
import unittest
from ConfigParser import ConfigParser
import os
import mock
from functools import partial
from six.moves.configparser import ConfigParser
from tempfile import NamedTemporaryFile
from test.unit import patch_policies, FakeRing, temptree
from swift.common.storage_policy import (

View File

@ -28,14 +28,15 @@ import os
import mock
import random
import re
from six import StringIO
from six.moves import range
import socket
import stat
import sys
import json
import math
from six import StringIO
from six.moves.queue import Queue, Empty
from six.moves import range
from textwrap import dedent
import tempfile
@ -47,7 +48,6 @@ import fcntl
import shutil
from contextlib import nested
from Queue import Queue, Empty
from getpass import getuser
from shutil import rmtree
from functools import partial