From 201b94d89fbd5c4d10abba210bbbe372065e707b Mon Sep 17 00:00:00 2001 From: chenyan Date: Thu, 30 Aug 2018 16:41:04 +0800 Subject: [PATCH] Fix dict related issues for Python 2/3 compatible code. Story: 2003429 Task: 24621 Change-Id: I71d9aa429abf8abef9b70e84e7437223a1b6719a Signed-off-by: chenyan Signed-off-by: Sun Austin --- .../cgcs_patch/api/controllers/root.py | 2 +- .../cgcs-patch/cgcs_patch/patch_agent.py | 2 +- .../cgcs-patch/cgcs_patch/patch_controller.py | 18 +++++++++--------- .../cgcs-patch/cgcs_patch/patch_functions.py | 2 +- .../patch_alarm/patch_alarm_manager.py | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py b/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py index 866a4549..2907362c 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/api/controllers/root.py @@ -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): diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py index 0f4c4f57..c3d63fb8 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_agent.py @@ -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 diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py index 93217cce..60a75d17 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py @@ -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 diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py index 73e64f13..c027f1cb 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_functions.py @@ -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, diff --git a/patch-alarm/patch-alarm/patch_alarm/patch_alarm_manager.py b/patch-alarm/patch-alarm/patch_alarm/patch_alarm_manager.py index 31c5c2be..fc0dba89 100644 --- a/patch-alarm/patch-alarm/patch_alarm/patch_alarm_manager.py +++ b/patch-alarm/patch-alarm/patch_alarm/patch_alarm_manager.py @@ -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