view changes for py3

Python3 changes several methods on dict's to views, requiring us to
convert them to lists.

Change-Id: Ib08c03564f198d1c08142c44bf9baac6a73816dd
This commit is contained in:
Clint Byrum 2017-05-10 19:40:53 -07:00
parent d52b7d7399
commit 1d0c7d1941
7 changed files with 12 additions and 12 deletions

View File

@ -2282,7 +2282,7 @@ class ZuulTestCase(BaseTestCase):
def countJobResults(self, jobs, result):
jobs = filter(lambda x: x.result == result, jobs)
return len(jobs)
return len(list(jobs))
def getJobFromHistory(self, name, project=None):
for job in self.history:

View File

@ -3339,7 +3339,7 @@ class TestScheduler(ZuulTestCase):
if time.time() - start > 10:
raise Exception("Timeout waiting for gearman server to report "
+ "back to the client")
build = self.executor.builds.values()[0]
build = list(self.executor.builds.values())[0]
if build.worker.name == "My Worker":
break
else:
@ -3512,7 +3512,7 @@ For CI problems and help debugging, contact ci@example.org"""
if time.time() - start > 10:
raise Exception("Timeout waiting for gearman server to report "
+ "back to the client")
build = self.executor_client.builds.values()[0]
build = list(self.executor_client.builds.values())[0]
if build.worker.name == "My Worker":
break
else:

View File

@ -111,7 +111,7 @@ class ZuulSafeLoader(yaml.SafeLoader):
r = super(ZuulSafeLoader, self).construct_mapping(node, deep)
keys = frozenset(r.keys())
if len(keys) == 1 and keys.intersection(self.zuul_node_types):
d = r.values()[0]
d = list(r.values())[0]
if isinstance(d, dict):
d['_start_mark'] = node.start_mark
d['_source_context'] = self.zuul_context
@ -493,7 +493,7 @@ class ProjectTemplateParser(object):
attrs = dict(name=conf_job)
elif isinstance(conf_job, dict):
# A dictionary in a job tree may override params
jobname, attrs = conf_job.items()[0]
jobname, attrs = list(conf_job.items())[0]
if attrs:
# We are overriding params, so make a new job def
attrs['name'] = jobname

View File

@ -369,7 +369,7 @@ class ExecutorServer(object):
self.command_socket.stop()
self.update_queue.put(None)
for job_worker in self.job_workers.values():
for job_worker in list(self.job_workers.values()):
try:
job_worker.stop()
except Exception:

View File

@ -426,7 +426,7 @@ class PipelineManager(object):
build.result = 'CANCELED'
canceled = True
canceled_jobs.add(build.job.name)
for jobname, nodeset in old_build_set.nodesets.items()[:]:
for jobname, nodeset in list(old_build_set.nodesets.items()):
if jobname in canceled_jobs:
continue
self.sched.nodepool.returnNodeSet(nodeset)

View File

@ -1206,7 +1206,7 @@ class BuildSet(object):
return self.builds.get(job_name)
def getBuilds(self):
keys = self.builds.keys()
keys = list(self.builds.keys())
keys.sort()
return [self.builds.get(x) for x in keys]
@ -2332,7 +2332,7 @@ class UnparsedAbideConfig(object):
raise Exception("Configuration item dictionaries must have "
"a single key (when parsing %s)" %
(conf,))
key, value = item.items()[0]
key, value = list(item.items())[0]
if key == 'tenant':
self.tenants.append(value)
else:
@ -2390,7 +2390,7 @@ class UnparsedTenantConfig(object):
raise Exception("Configuration item dictionaries must have "
"a single key (when parsing %s)" %
(conf,))
key, value = item.items()[0]
key, value = list(item.items())[0]
if key == 'project':
name = value['name']
self.projects.setdefault(name, []).append(value)
@ -2697,7 +2697,7 @@ class Tenant(object):
if hostname:
project = hostname_dict.get(hostname)
else:
values = hostname_dict.values()
values = list(hostname_dict.values())
if len(values) == 1:
project = values[0]
else:

View File

@ -168,7 +168,7 @@ class ZooKeeper(object):
if data:
data = self._strToDict(data)
node_request.updateFromDict(data)
request_nodes = node_request.nodeset.getNodes()
request_nodes = list(node_request.nodeset.getNodes())
for i, nodeid in enumerate(data.get('nodes', [])):
node_path = '%s/%s' % (self.NODE_ROOT, nodeid)
node_data, node_stat = self.client.get(node_path)