Mercurial > libervia-backend
comparison sat/tools/config.py @ 3148:60a9e47ef988
core: log filenames of read config files
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 29 Jan 2020 19:42:02 +0100 |
parents | 559a625a236b |
children | a3639d6d9643 |
comparison
equal
deleted
inserted
replaced
3147:c3e8ddf3a071 | 3148:60a9e47ef988 |
---|---|
97 "versions (< 0.5)" | 97 "versions (< 0.5)" |
98 )) | 98 )) |
99 fixConfigOption("", "local_dir", old_default, silent) | 99 fixConfigOption("", "local_dir", old_default, silent) |
100 | 100 |
101 | 101 |
102 def parseMainConf(): | 102 def parseMainConf(log_filenames=False): |
103 """look for main .ini configuration file, and parse it""" | 103 """Look for main .ini configuration file, and parse it |
104 | |
105 @param log_filenames(bool): if True, log filenames of read config files | |
106 """ | |
104 config = ConfigParser(defaults=C.DEFAULT_CONFIG) | 107 config = ConfigParser(defaults=C.DEFAULT_CONFIG) |
105 try: | 108 try: |
106 config.read(C.CONFIG_FILES) | 109 filenames = config.read(C.CONFIG_FILES) |
107 except Exception as e: | 110 except Exception as e: |
108 log.error(_("Can't read main config: {msg}").format(msg=e), exc_info=True) | 111 log.error(_("Can't read main config: {msg}").format(msg=e), exc_info=True) |
112 else: | |
113 if log_filenames: | |
114 log.info( | |
115 _("Configuration was read from: {filenames}").format( | |
116 filenames=', '.join(filenames))) | |
117 | |
109 return config | 118 return config |
110 | 119 |
111 | 120 |
112 def getConfig(config, section, name, default=None): | 121 def getConfig(config, section, name, default=None): |
113 """Get a configuration option | 122 """Get a configuration option |