Fix dict related issues for Python 2/3 compatible code.
Story: 2003429 Task: 24621 Change-Id: I71d9aa429abf8abef9b70e84e7437223a1b6719a Signed-off-by: chenyan <yan.chen@intel.com> Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
7777f0a7f4
commit
201b94d89f
@ -129,7 +129,7 @@ class PatchAPIController(object):
|
||||
@expose('json')
|
||||
def upload_dir(self, **kwargs):
|
||||
files = []
|
||||
for key, path in kwargs.iteritems():
|
||||
for key, path in kwargs.items():
|
||||
LOG.info("upload-dir: Retrieving patches from %s" % path)
|
||||
for f in glob.glob(path + '/*.patch'):
|
||||
if os.path.isfile(f):
|
||||
|
@ -768,7 +768,7 @@ class PatchAgent(PatchService):
|
||||
print("Checking for software updates...")
|
||||
self.query()
|
||||
install_set = []
|
||||
for pkg, version in self.to_install.iteritems():
|
||||
for pkg, version in self.to_install.items():
|
||||
install_set.append("%s-%s" % (pkg, version))
|
||||
|
||||
install_set += self.missing_pkgs
|
||||
|
@ -1013,7 +1013,7 @@ class PatchController(PatchService):
|
||||
|
||||
# Now verify the state of the required patches
|
||||
req_verification = True
|
||||
for req_patch, iter_patch_list in required_patches.iteritems():
|
||||
for req_patch, iter_patch_list in required_patches.items():
|
||||
if req_patch not in self.patch_data.metadata \
|
||||
or self.patch_data.metadata[req_patch]["repostate"] == constants.AVAILABLE:
|
||||
msg = "%s is required by: %s" % (req_patch, ", ".join(sorted(iter_patch_list)))
|
||||
@ -1105,7 +1105,7 @@ class PatchController(PatchService):
|
||||
if repo_changed:
|
||||
# Update the repo
|
||||
self.patch_data.gen_groups_xml()
|
||||
for ver, rdir in repo_dir.iteritems():
|
||||
for ver, rdir in repo_dir.items():
|
||||
try:
|
||||
output = subprocess.check_output(["createrepo",
|
||||
"--update",
|
||||
@ -1201,7 +1201,7 @@ class PatchController(PatchService):
|
||||
required_patches[req_patch].append(patch_iter)
|
||||
|
||||
if len(required_patches) > 0:
|
||||
for req_patch, iter_patch_list in required_patches.iteritems():
|
||||
for req_patch, iter_patch_list in required_patches.items():
|
||||
msg = "%s is required by: %s" % (req_patch, ", ".join(sorted(iter_patch_list)))
|
||||
msg_error += msg + "\n"
|
||||
LOG.info(msg)
|
||||
@ -1265,7 +1265,7 @@ class PatchController(PatchService):
|
||||
if repo_changed:
|
||||
# Update the repo
|
||||
self.patch_data.gen_groups_xml()
|
||||
for ver, rdir in repo_dir.iteritems():
|
||||
for ver, rdir in repo_dir.items():
|
||||
try:
|
||||
output = subprocess.check_output(["createrepo",
|
||||
"--update",
|
||||
@ -1629,7 +1629,7 @@ class PatchController(PatchService):
|
||||
results = self.patch_data.metadata
|
||||
else:
|
||||
# Filter results
|
||||
for patch_id, data in self.patch_data.metadata.iteritems():
|
||||
for patch_id, data in self.patch_data.metadata.items():
|
||||
if query_state is not None and data["repostate"] != query_state:
|
||||
continue
|
||||
if query_release is not None and data["sw_version"] != query_release:
|
||||
@ -1652,10 +1652,10 @@ class PatchController(PatchService):
|
||||
if patch_id not in self.patch_data.metadata.keys():
|
||||
results["error"] += "%s is unrecognized\n" % patch_id
|
||||
|
||||
for patch_id, data in self.patch_data.metadata.iteritems():
|
||||
for patch_id, data in self.patch_data.metadata.items():
|
||||
if patch_id in patch_ids:
|
||||
results["metadata"][patch_id] = data
|
||||
for patch_id, data in self.patch_data.contents.iteritems():
|
||||
for patch_id, data in self.patch_data.contents.items():
|
||||
if patch_id in patch_ids:
|
||||
results["contents"][patch_id] = data
|
||||
|
||||
@ -1895,7 +1895,7 @@ class PatchController(PatchService):
|
||||
|
||||
# Update the repo
|
||||
self.patch_data.gen_groups_xml()
|
||||
for ver, rdir in repo_dir.iteritems():
|
||||
for ver, rdir in repo_dir.items():
|
||||
try:
|
||||
output = subprocess.check_output(["createrepo",
|
||||
"--update",
|
||||
@ -1935,7 +1935,7 @@ class PatchController(PatchService):
|
||||
rc = False
|
||||
|
||||
self.hosts_lock.acquire()
|
||||
for ip, host in self.hosts.iteritems():
|
||||
for ip, host in self.hosts.items():
|
||||
if host.state == constants.PATCH_AGENT_STATE_INSTALLING:
|
||||
rc = True
|
||||
break
|
||||
|
@ -600,7 +600,7 @@ class PatchData:
|
||||
write_xml_file(top, fname)
|
||||
|
||||
def gen_groups_xml(self):
|
||||
for ver, rdir in repo_dir.iteritems():
|
||||
for ver, rdir in repo_dir.items():
|
||||
self.gen_release_groups_xml(ver)
|
||||
|
||||
def query_line(self,
|
||||
|
@ -92,7 +92,7 @@ class PatchAlarmDaemon():
|
||||
data = json.loads(req.text)
|
||||
|
||||
if 'pd' in data:
|
||||
for patch_id, metadata in data['pd'].iteritems():
|
||||
for patch_id, metadata in data['pd'].items():
|
||||
if 'patchstate' in metadata and \
|
||||
(metadata['patchstate'] == 'Partial-Apply' or metadata['patchstate'] == 'Partial-Remove'):
|
||||
raise_pip_alarm = True
|
||||
|
Loading…
Reference in New Issue
Block a user