diff --git a/swift/common/constraints.py b/swift/common/constraints.py index 647f875609..aae5f25aac 100644 --- a/swift/common/constraints.py +++ b/swift/common/constraints.py @@ -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, \ diff --git a/swift/common/container_sync_realms.py b/swift/common/container_sync_realms.py index 083c5e1fd9..7b441da9de 100644 --- a/swift/common/container_sync_realms.py +++ b/swift/common/container_sync_realms.py @@ -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) diff --git a/swift/common/direct_client.py b/swift/common/direct_client.py index 9d36757649..5d78fe641a 100644 --- a/swift/common/direct_client.py +++ b/swift/common/direct_client.py @@ -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 diff --git a/swift/common/middleware/dlo.py b/swift/common/middleware/dlo.py index 9330ccb8cb..882d21f305 100644 --- a/swift/common/middleware/dlo.py +++ b/swift/common/middleware/dlo.py @@ -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 diff --git a/swift/common/middleware/memcache.py b/swift/common/middleware/memcache.py index 1b66716b15..e846749cb0 100644 --- a/swift/common/middleware/memcache.py +++ b/swift/common/middleware/memcache.py @@ -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) diff --git a/swift/common/storage_policy.py b/swift/common/storage_policy.py index 415aa55377..b3b460656c 100644 --- a/swift/common/storage_policy.py +++ b/swift/common/storage_policy.py @@ -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 diff --git a/swift/common/utils.py b/swift/common/utils.py index 40a5b85232..1bcaa948b2 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -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 _ diff --git a/test/functional/__init__.py b/test/functional/__init__.py index 288f0f0140..8f16f5ac23 100644 --- a/test/functional/__init__.py +++ b/test/functional/__init__.py @@ -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 diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index 465e25d7ed..a1a775ab98 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -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 diff --git a/test/probe/common.py b/test/probe/common.py index 093194aed9..bf0e61d298 100644 --- a/test/probe/common.py +++ b/test/probe/common.py @@ -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 diff --git a/test/probe/test_account_get_fake_responses_match.py b/test/probe/test_account_get_fake_responses_match.py index f99b41e780..46ddb16de0 100755 --- a/test/probe/test_account_get_fake_responses_match.py +++ b/test/probe/test_account_get_fake_responses_match.py @@ -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: diff --git a/test/unit/__init__.py b/test/unit/__init__.py index a5d77062fe..4db4373008 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -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 diff --git a/test/unit/common/middleware/test_memcache.py b/test/unit/common/middleware/test_memcache.py index d45fca7e89..44c4fc3987 100644 --- a/test/unit/common/middleware/test_memcache.py +++ b/test/unit/common/middleware/test_memcache.py @@ -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 diff --git a/test/unit/common/test_storage_policy.py b/test/unit/common/test_storage_policy.py index 1a8289d613..c7c0453c17 100644 --- a/test/unit/common/test_storage_policy.py +++ b/test/unit/common/test_storage_policy.py @@ -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 ( diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index a786ec0d88..b5dc6edf32 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -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