diff --git a/swift/cli/ringbuilder.py b/swift/cli/ringbuilder.py index eaaeaa6d9f..702ecb8569 100755 --- a/swift/cli/ringbuilder.py +++ b/swift/cli/ringbuilder.py @@ -18,7 +18,7 @@ from __future__ import print_function import logging from errno import EEXIST -from itertools import islice, izip +from itertools import islice from operator import itemgetter from os import mkdir from os.path import basename, abspath, dirname, exists, join as pathjoin @@ -27,6 +27,8 @@ from textwrap import wrap from time import time import optparse import math + +from six.moves import zip as izip from six.moves import input from swift.common import exceptions diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py index a43887173f..8d4802f6ef 100644 --- a/swift/common/ring/builder.py +++ b/swift/common/ring/builder.py @@ -27,6 +27,7 @@ import warnings from array import array from collections import defaultdict +import six from six.moves import range from time import time @@ -501,7 +502,7 @@ class RingBuilder(object): dispersion_graph = {} # go over all the devices holding each replica part by part for part_id, dev_ids in enumerate( - itertools.izip(*self._replica2part2dev)): + six.moves.zip(*self._replica2part2dev)): # count the number of replicas of this part for each tier of each # device, some devices may have overlapping tiers! replicas_at_tier = defaultdict(int) diff --git a/swift/obj/reconstructor.py b/swift/obj/reconstructor.py index 5793b3eda2..9ead83b1ac 100644 --- a/swift/obj/reconstructor.py +++ b/swift/obj/reconstructor.py @@ -19,6 +19,7 @@ import random import time import itertools from collections import defaultdict +import six import six.moves.cPickle as pickle import shutil @@ -799,7 +800,7 @@ class ObjectReconstructor(Daemon): self._diskfile_mgr = self._df_router[policy] self.load_object_ring(policy) data_dir = get_data_dir(policy) - local_devices = list(itertools.ifilter( + local_devices = list(six.moves.filter( lambda dev: dev and is_local_device( ips, self.port, dev['replication_ip'], dev['replication_port']), diff --git a/swift/obj/ssync_sender.py b/swift/obj/ssync_sender.py index 0003a0c05d..51dbed32a3 100644 --- a/swift/obj/ssync_sender.py +++ b/swift/obj/ssync_sender.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import six from six.moves import urllib -from itertools import ifilter from swift.common import bufferedhttp from swift.common import exceptions from swift.common import http @@ -266,7 +266,7 @@ class Sender(object): self.job['policy'], self.suffixes, frag_index=self.job.get('frag_index')) if self.remote_check_objs is not None: - hash_gen = ifilter( + hash_gen = six.moves.filter( lambda path_objhash_timestamps: path_objhash_timestamps[1] in self.remote_check_objs, hash_gen) diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index 5a8f3163de..baf0dd4a70 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -24,6 +24,7 @@ # These shenanigans are to ensure all related objects can be garbage # collected. We've seen objects hang around forever otherwise. +import six from six.moves.urllib.parse import unquote, quote import collections @@ -164,15 +165,15 @@ class BaseObjectController(Controller): all_nodes = itertools.chain(primary_nodes, ring.get_more_nodes(partition)) first_n_local_nodes = list(itertools.islice( - itertools.ifilter(is_local, all_nodes), num_locals)) + six.moves.filter(is_local, all_nodes), num_locals)) # refresh it; it moved when we computed first_n_local_nodes all_nodes = itertools.chain(primary_nodes, ring.get_more_nodes(partition)) local_first_node_iter = itertools.chain( first_n_local_nodes, - itertools.ifilter(lambda node: node not in first_n_local_nodes, - all_nodes)) + six.moves.filter(lambda node: node not in first_n_local_nodes, + all_nodes)) return self.app.iter_nodes( ring, partition, node_iter=local_first_node_iter)