confighelper: use read_file() rather than read()

The read() method will return an empty list if the file specified
does not exist or if the read failed in some fashion.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-02-15 11:42:50 -05:00
parent 0e27a949af
commit e2d92b5575

View File

@ -378,7 +378,7 @@ class ConfigHelper:
f"Configuration File Not Found: '{cfg_file_path}''") f"Configuration File Not Found: '{cfg_file_path}''")
try: try:
sup_cfg = configparser.ConfigParser(interpolation=None) sup_cfg = configparser.ConfigParser(interpolation=None)
sup_cfg.read(cfg_file_path) sup_cfg.read_file(open(cfg_file_path))
except Exception: except Exception:
raise ConfigError(f"Error Reading Config: '{cfg_file_path}'") raise ConfigError(f"Error Reading Config: '{cfg_file_path}'")
sections = sup_cfg.sections() sections = sup_cfg.sections()
@ -416,7 +416,7 @@ def get_configuration(server: Server,
app_args['config_file'])) app_args['config_file']))
config = configparser.ConfigParser(interpolation=None) config = configparser.ConfigParser(interpolation=None)
try: try:
config.read(cfg_file_path) config.read_file(open(cfg_file_path))
except Exception as e: except Exception as e:
if not os.path.isfile(cfg_file_path): if not os.path.isfile(cfg_file_path):
raise ConfigError( raise ConfigError(