From fdb7fc44982f655ef6a3853eba3ae61ee9f3ea3d Mon Sep 17 00:00:00 2001 From: "ting.wang" Date: Sat, 16 Jan 2016 10:19:43 +0800 Subject: [PATCH] Py3: use dict.items() instead of dict.iteritems() Python 3 use dict.items(), so we'd better use it. Change-Id: I41380ebbed60bd33cc7e2494c5c3b226fedec3ac --- astara/event.py | 2 +- astara/pez/pool.py | 6 +++--- astara/test/unit/drivers/test_factory.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/astara/event.py b/astara/event.py index 6a269a52..a750ff82 100644 --- a/astara/event.py +++ b/astara/event.py @@ -48,7 +48,7 @@ class Event(object): def __eq__(self, other): if not type(self) == type(other): return False - for k, v in vars(self).iteritems(): + for k, v in vars(self).items(): if k not in vars(other): return False if vars(other)[k] != v: diff --git a/astara/pez/pool.py b/astara/pez/pool.py index 8fb1f192..53f43ecb 100644 --- a/astara/pez/pool.py +++ b/astara/pez/pool.py @@ -123,7 +123,7 @@ class PezPoolManager(object): def _check_err_instances(self, pools): """Scans the pool and deletes any instances in error state""" - for resource, pool in copy.copy(pools).iteritems(): + for resource, pool in copy.copy(pools).items(): err_instances = [i for i in pool if i.status == ERROR] for err_inst in err_instances: LOG.error(_LE( @@ -140,7 +140,7 @@ class PezPoolManager(object): # out what to do with them later. stuck_instances = [] del_instances = [] - for resource, pool in pools.iteritems(): + for resource, pool in pools.items(): del_instances += [i for i in pool if i.status == DELETING] # clean out counters for old instances that have been deleted entirely @@ -164,7 +164,7 @@ class PezPoolManager(object): def _check_outdated_instances(self, pools): outdated_instances = [] - for resource, pool in pools.iteritems(): + for resource, pool in pools.items(): for server in pool: if server.image['id'] != str(self.images[resource]): LOG.info(_LI( diff --git a/astara/test/unit/drivers/test_factory.py b/astara/test/unit/drivers/test_factory.py index 006602c3..f0af4340 100644 --- a/astara/test/unit/drivers/test_factory.py +++ b/astara/test/unit/drivers/test_factory.py @@ -19,7 +19,7 @@ from astara import drivers class DriverFactoryTest(base.RugTestBase): def test_get_driver(self): - for k, v in drivers.AVAILABLE_DRIVERS.iteritems(): + for k, v in drivers.AVAILABLE_DRIVERS.items(): self.assertEqual(drivers.get(k), v) def test_get_bad_driver(self):