From 20c212cee5738cb491bf77b1f6cf3e8aa6bfca17 Mon Sep 17 00:00:00 2001 From: Sangita Maity Date: Tue, 2 Jun 2020 23:19:04 +0000 Subject: [PATCH] Removed legacy 'portmap.ini' and fixed LGTM issue Signed-off-by: Sangita Maity --- src/sonic-config-engine/portconfig.py | 6 +++--- src/sonic-daemon-base/sonic_daemon_base/daemon_base.py | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/sonic-config-engine/portconfig.py b/src/sonic-config-engine/portconfig.py index 8bf0e98ad86b..95ffcc28cacb 100644 --- a/src/sonic-config-engine/portconfig.py +++ b/src/sonic-config-engine/portconfig.py @@ -41,7 +41,7 @@ def readJson(filename): print("Json file does not exist") data_dict = ast.literal_eval(json.dumps(data)) return data_dict - except: + except Exception as e: print("error occurred while parsing json:", sys.exc_info()[1]) return None @@ -54,7 +54,7 @@ def db_connect_configdb(): return None try: config_db.connect() - except: + except Exception as e: config_db = None return config_db @@ -109,7 +109,7 @@ def get_port_config(hwsku=None, platform=None, port_config_file=None, hwsku_conf port_alias_map = {} port_alias_asic_map = {} for intf_name in ports.keys(): - port_alias_map[ports[intf_name]["alias"]]= intf_name + port_alias_map[ports[intf_name]["alias"]] = intf_name return (ports, port_alias_map, port_alias_asic_map) if not port_config_file: diff --git a/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py b/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py index 8f932b2c9e39..481e1db65b31 100644 --- a/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py +++ b/src/sonic-daemon-base/sonic_daemon_base/daemon_base.py @@ -27,7 +27,6 @@ # Port config information PORT_CONFIG = 'port_config.ini' -PORTMAP = 'portmap.ini' PLATFORM_CAP = 'platform.json' EEPROM_MODULE_NAME = 'eeprom' @@ -159,10 +158,7 @@ def get_path_to_port_config_file(self): # platform.json doesn't exist. Try loading the legacy 'port_config.ini' file port_config_file_path = "/".join([hwsku_path, PORT_CONFIG]) if not os.path.isfile(port_config_file_path): - # port_config.ini doesn't exist. Try loading the legacy 'portmap.ini' file - port_config_file_path = "/".join([hwsku_path, PORTMAP]) - if not os.path.isfile(port_config_file_path): - raise IOError("Failed to detect port config file: %s" % (port_config_file_path)) + raise IOError("Failed to detect port config file: %s" % (port_config_file_path)) return port_config_file_path