Merge "Python3 readiness for congress (misc changes)"

This commit is contained in:
Jenkins 2015-12-08 22:05:22 +00:00 committed by Gerrit Code Review
commit 3a97a844e8
5 changed files with 10 additions and 9 deletions

View File

@ -437,7 +437,8 @@ class deepSix(greenthread.GreenThread):
elif key and dataindex:
for corruuid in self.subdata.keys():
for corruuid in self.subdata.copy().keys():
# copy to avoid undefined behavior w changing dict during iter
if (key == self.subdata[corruuid].key and
dataindex == self.subdata[corruuid].dataindex):

View File

@ -533,7 +533,7 @@ class Runtime (object):
def policy_names(self):
"""Returns list of policy names."""
return self.theory.keys()
return list(self.theory.keys())
def policy_object(self, name=None, id=None):
"""Return policy by given name. Raises KeyError if does not exist."""
@ -1846,7 +1846,7 @@ class DseRuntime (Runtime, deepsix.deepSix):
subs = self.pubdata[dataindex].getsubscribers()
# The sender is the last subscriber
# inunsub() will remove it from pubdata[dataindex] later
if [sender] == subs.keys():
if [sender] == list(subs.keys()):
sub = self.policySubData.pop((tablename, policy, None))
self.trigger_registry.unregister(sub.trigger())
@ -1906,7 +1906,7 @@ class DseRuntime (Runtime, deepsix.deepSix):
self.execution_triggers[table] = trig
# remove triggers no longer needed
# Using copy of execution_trigger keys so we can delete inside loop
for table in self.execution_triggers.keys():
for table in self.execution_triggers.copy().keys():
LOG.debug("%s:: checking for stale trigger table %s",
self.name, table)
if table not in curr_tables:

View File

@ -652,8 +652,8 @@ class VmMigrator(object):
def getnext(cls, mapping, status):
hi = max(status.values())
if hi > 0:
i = status.values().index(hi)
return status.keys()[i]
i = list(status.values()).index(hi)
return list(status.keys())[i]
@classmethod
def do_migrations(cls, g_h_mapping):

View File

@ -147,7 +147,7 @@ class TestDSE(base.TestCase):
policy.insert('p(x):-data:q(x),gt(x,2)', target='classification')
data.subscribe('policy', 'classification:p', callback=data.receive_msg)
helper.retry_check_subscribers(policy, [('data', 'classification:p')])
self.assertEqual(policy.policySubData.keys(),
self.assertEqual(list(policy.policySubData.keys()),
[('p', 'classification', None)])
policy.insert('q(1)', target='data')
# no entry here
@ -173,4 +173,4 @@ class TestDSE(base.TestCase):
# trigger removed
helper.retry_check_no_subscribers(policy,
[('data', 'classification:p')])
self.assertEqual(policy.policySubData.keys(), [])
self.assertEqual(list(policy.policySubData.keys()), [])

View File

@ -296,7 +296,7 @@ def check_subscribers(deepsix, subscriber_list):
all subscribers exist; otherwise returns False.
"""
actual = set([(name, pubdata.dataindex)
for pubdata in deepsix.pubdata.values()
for pubdata in deepsix.pubdata.copy().values()
for name in pubdata.subscribers])
correct = set(subscriber_list)
missing = correct - actual