Mercurial > libervia-web
comparison twisted/plugins/libervia_server.py @ 1509:106bae41f5c8
massive refactoring from camelCase -> snake_case. See backend commit log for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:44:11 +0200 |
parents | 7e63fdb272e5 |
children | eb00d593801d |
comparison
equal
deleted
inserted
replaced
1508:ec3ad9abf9f9 | 1509:106bae41f5c8 |
---|---|
158 """Method to initialise global modules""" | 158 """Method to initialise global modules""" |
159 # XXX: We need to configure logs before any log method is used, | 159 # XXX: We need to configure logs before any log method is used, |
160 # so here is the best place. | 160 # so here is the best place. |
161 from sat.core import log_config | 161 from sat.core import log_config |
162 | 162 |
163 log_config.satConfigure(C.LOG_BACKEND_TWISTED, C, backend_data=options) | 163 log_config.sat_configure(C.LOG_BACKEND_TWISTED, C, backend_data=options) |
164 | 164 |
165 | 165 |
166 class Options(usage.Options): | 166 class Options(usage.Options): |
167 # optArgs is not really useful in our case, we need more than a flag | 167 # optArgs is not really useful in our case, we need more than a flag |
168 optParameters = OPT_PARAMETERS_BOTH | 168 optParameters = OPT_PARAMETERS_BOTH |
180 # there's no good way to know | 180 # there's no good way to know |
181 # if the options values are the hard-coded ones or if they have been passed | 181 # if the options values are the hard-coded ones or if they have been passed |
182 # on the command line. | 182 # on the command line. |
183 | 183 |
184 # FIXME: must be refactored + code can be factorised with backend | 184 # FIXME: must be refactored + code can be factorised with backend |
185 config_parser = config.parseMainConf() | 185 config_parser = config.parse_main_conf() |
186 self.handleDeprecated(config_parser) | 186 self.handleDeprecated(config_parser) |
187 for param in self.optParameters + OPT_PARAMETERS_CFG: | 187 for param in self.optParameters + OPT_PARAMETERS_CFG: |
188 name = param[0] | 188 name = param[0] |
189 env_name = f"{ENV_PREFIX}{name.upper()}" | 189 env_name = f"{ENV_PREFIX}{name.upper()}" |
190 try: | 190 try: |
191 value = os.getenv(env_name) | 191 value = os.getenv(env_name) |
192 if value is None: | 192 if value is None: |
193 value = config.getConfig( | 193 value = config.config_get( |
194 config_parser, C.CONFIG_SECTION, name, Exception) | 194 config_parser, C.CONFIG_SECTION, name, Exception) |
195 try: | 195 try: |
196 param[2] = param[4](value) | 196 param[2] = param[4](value) |
197 except IndexError: # the coerce method is optional | 197 except IndexError: # the coerce method is optional |
198 param[2] = value | 198 param[2] = value |
208 param config_parser(ConfigParser): read ConfigParser instance for sat.conf | 208 param config_parser(ConfigParser): read ConfigParser instance for sat.conf |
209 """ | 209 """ |
210 replacements = (("ssl_certificate", "tls_certificate"),) | 210 replacements = (("ssl_certificate", "tls_certificate"),) |
211 for old, new in replacements: | 211 for old, new in replacements: |
212 try: | 212 try: |
213 value = config.getConfig(config_parser, C.CONFIG_SECTION, old, Exception) | 213 value = config.config_get(config_parser, C.CONFIG_SECTION, old, Exception) |
214 except (configparser.NoSectionError, configparser.NoOptionError): | 214 except (configparser.NoSectionError, configparser.NoOptionError): |
215 pass | 215 pass |
216 else: | 216 else: |
217 print(("\n/!\\ Use of {old} is deprecated, please use {new} instead\n" | 217 print(("\n/!\\ Use of {old} is deprecated, please use {new} instead\n" |
218 .format(old=old, new=new))) | 218 .format(old=old, new=new))) |