Optimize Glances configuration file path search

This commit is contained in:
nicolargo 2024-05-28 13:49:11 +02:00
parent 2379ec6b55
commit 5a78e72419
2 changed files with 3 additions and 2 deletions

View File

@ -117,6 +117,7 @@ class Config:
self.config_dir = config_dir
self.config_filename = 'glances.conf'
self._loaded_config_file = None
self._config_file_paths = self.config_file_paths()
# Re pattern for optimize research of `foo`
self.re_pattern = re.compile(r'(\`.+?\`)')
@ -164,7 +165,7 @@ class Config:
def read(self):
"""Read the config file, if it exists. Using defaults otherwise."""
for config_file in self.config_file_paths():
for config_file in self._config_file_paths:
logger.debug(f'Search glances.conf file in {config_file}')
if os.path.exists(config_file):
try:

View File

@ -95,7 +95,7 @@ class GlancesPluginModel:
# Init the limits (configuration keys) dictionary
self._limits = {}
if config is not None:
logger.debug(f'Load section {self.plugin_name} in {config.config_file_paths()}')
logger.debug(f'Load section {self.plugin_name} in Glances configuration file')
self.load_limits(config=config)
# Init the alias (dictionnary)