diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/authapi/app.py b/cgcs-patch/cgcs-patch/cgcs_patch/authapi/app.py index 2d08ddc7..4eed6d20 100755 --- a/cgcs-patch/cgcs-patch/cgcs_patch/authapi/app.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/authapi/app.py @@ -13,7 +13,7 @@ from cgcs_patch.authapi import config from cgcs_patch.authapi import hooks from cgcs_patch.authapi import policy -import ConfigParser +from six.moves import configparser auth_opts = [ cfg.StrOpt('auth_strategy', @@ -32,7 +32,7 @@ def get_pecan_config(): def setup_app(pecan_config=None, extra_hooks=None): - config_parser = ConfigParser.RawConfigParser() + config_parser = configparser.RawConfigParser() config_parser.read('/etc/patching/patching.conf') policy.init() diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/config.py b/cgcs-patch/cgcs-patch/cgcs_patch/config.py index 3a17b432..bb43933f 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/config.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/config.py @@ -6,8 +6,8 @@ SPDX-License-Identifier: Apache-2.0 """ import os -import ConfigParser -import StringIO +from six.moves import configparser +import io import logging import socket import cgcs_patch.utils as utils @@ -48,7 +48,7 @@ def read_config(): global controller_port global agent_port - config = ConfigParser.SafeConfigParser(defaults) + config = configparser.SafeConfigParser(defaults) config.read(patching_conf) patching_conf_mtime = os.stat(patching_conf).st_mtime @@ -62,8 +62,8 @@ def read_config(): # The platform.conf file has no section headers, which causes problems # for ConfigParser. So we'll fake it out. - ini_str = '[platform_conf]\n' + open(tsc.PLATFORM_CONF_FILE, 'r').read() - ini_fp = StringIO.StringIO(ini_str) + ini_str = u'[platform_conf]\n' + open(tsc.PLATFORM_CONF_FILE, 'r').read() + ini_fp = io.StringIO(ini_str) config.readfp(ini_fp) try: @@ -71,7 +71,7 @@ def read_config(): global nodetype nodetype = value - except ConfigParser.Error: + except configparser.Error: logging.exception("Failed to read nodetype from config") return False @@ -103,12 +103,12 @@ def get_mgmt_iface(): # so return the cached value. return mgmt_if - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() # The platform.conf file has no section headers, which causes problems # for ConfigParser. So we'll fake it out. - ini_str = '[platform_conf]\n' + open(tsc.PLATFORM_CONF_FILE, 'r').read() - ini_fp = StringIO.StringIO(ini_str) + ini_str = u'[platform_conf]\n' + open(tsc.PLATFORM_CONF_FILE, 'r').read() + ini_fp = io.StringIO(ini_str) config.readfp(ini_fp) try: @@ -118,7 +118,7 @@ def get_mgmt_iface(): mgmt_if = value platform_conf_mtime = os.stat(tsc.PLATFORM_CONF_FILE).st_mtime - except ConfigParser.Error: + except configparser.Error: logging.exception("Failed to read management_interface from config") return None return mgmt_if diff --git a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py index 8b6a4eed..93217cce 100644 --- a/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py +++ b/cgcs-patch/cgcs-patch/cgcs_patch/patch_controller.py @@ -11,7 +11,7 @@ import socket import json import select import subprocess -import ConfigParser +from six.moves import configparser import rpm import os @@ -592,7 +592,7 @@ class PatchController(PatchService): pass def write_state_file(self): - config = ConfigParser.ConfigParser() + config = configparser.ConfigParser() cfgfile = open(state_file, 'w') @@ -602,7 +602,7 @@ class PatchController(PatchService): cfgfile.close() def read_state_file(self): - config = ConfigParser.ConfigParser() + config = configparser.ConfigParser() config.read(state_file) @@ -611,7 +611,7 @@ class PatchController(PatchService): self.patch_op_counter = counter LOG.info("patch_op_counter is: %d" % self.patch_op_counter) - except ConfigParser.Error: + except configparser.Error: LOG.exception("Failed to read state info") def handle_nbr_patch_op_counter(self, host, nbr_patch_op_counter): diff --git a/tsconfig/tsconfig/tsconfig/tsconfig.py b/tsconfig/tsconfig/tsconfig/tsconfig.py index 11da04a0..cc90ce8d 100644 --- a/tsconfig/tsconfig/tsconfig/tsconfig.py +++ b/tsconfig/tsconfig/tsconfig/tsconfig.py @@ -6,8 +6,8 @@ SPDX-License-Identifier: Apache-2.0 """ import os -import ConfigParser -import StringIO +from six.moves import configparser +import io import logging SW_VERSION = "" @@ -54,17 +54,17 @@ def _load(): # The build.info file has no section headers, which causes problems # for ConfigParser. So we'll fake it out. - ini_str = '[build_info]\n' + open(build_info, 'r').read() - ini_fp = StringIO.StringIO(ini_str) + ini_str = u'[build_info]\n' + open(build_info, 'r').read() + ini_fp = io.StringIO(ini_str) - config = ConfigParser.SafeConfigParser() + config = configparser.SafeConfigParser() config.readfp(ini_fp) try: value = config.get('build_info', 'SW_VERSION') SW_VERSION = value.strip('"') - except ConfigParser.Error: + except configparser.Error: logging.exception("Failed to read SW_VERSION from /etc/build.info") return False @@ -72,8 +72,8 @@ def _load(): # The platform.conf file has no section headers, which causes problems # for ConfigParser. So we'll fake it out. - ini_str = '[platform_conf]\n' + open(PLATFORM_CONF_FILE, 'r').read() - ini_fp = StringIO.StringIO(ini_str) + ini_str = u'[platform_conf]\n' + open(PLATFORM_CONF_FILE, 'r').read() + ini_fp = io.StringIO(ini_str) config.readfp(ini_fp) try: @@ -147,7 +147,7 @@ def _load(): if config.has_option('platform_conf', 'security_feature'): security_feature = config.get('platform_conf', 'security_feature') - except ConfigParser.Error: + except configparser.Error: logging.exception("Failed to read platform.conf") return False