comparison twisted/plugins/libervia_server.py @ 1275:334d044f2713

server: default theme can now be specified in site section of `sat.conf` with `theme` key
author Goffi <goffi@goffi.org>
date Fri, 19 Jun 2020 16:47:50 +0200
parents f511f8fbbf8a
children 2da573bf3f8b
comparison
equal deleted inserted replaced
1274:eb4f03da0d7d 1275:334d044f2713
47 from twisted.plugin import IPlugin 47 from twisted.plugin import IPlugin
48 from twisted.application.service import IServiceMaker 48 from twisted.application.service import IServiceMaker
49 import configparser 49 import configparser
50 50
51 51
52 CONFIG_SECTION = C.APP_NAME.lower()
53 if libervia.__version__ != sat.__version__: 52 if libervia.__version__ != sat.__version__:
54 import sys 53 import sys
55 54
56 sys.stderr.write( 55 sys.stderr.write(
57 """sat module version ({sat_version}) and {current_app} version ({current_version}) mismatch 56 """sat module version ({sat_version}) and {current_app} version ({current_version}) mismatch
183 config_parser.read(C.CONFIG_FILES) 182 config_parser.read(C.CONFIG_FILES)
184 self.handleDeprecated(config_parser) 183 self.handleDeprecated(config_parser)
185 for param in self.optParameters + OPT_PARAMETERS_CFG: 184 for param in self.optParameters + OPT_PARAMETERS_CFG:
186 name = param[0] 185 name = param[0]
187 try: 186 try:
188 value = config.getConfig(config_parser, CONFIG_SECTION, name, Exception) 187 value = config.getConfig(config_parser, C.CONFIG_SECTION, name, Exception)
189 # if isinstance(value, str): 188 # if isinstance(value, str):
190 # value = value.encode("utf-8") 189 # value = value.encode("utf-8")
191 try: 190 try:
192 param[2] = param[4](value) 191 param[2] = param[4](value)
193 except IndexError: # the coerce method is optional 192 except IndexError: # the coerce method is optional
204 param config_parser(ConfigParser): read ConfigParser instance for sat.conf 203 param config_parser(ConfigParser): read ConfigParser instance for sat.conf
205 """ 204 """
206 replacements = (("ssl_certificate", "tls_certificate"),) 205 replacements = (("ssl_certificate", "tls_certificate"),)
207 for old, new in replacements: 206 for old, new in replacements:
208 try: 207 try:
209 value = config.getConfig(config_parser, CONFIG_SECTION, old, Exception) 208 value = config.getConfig(config_parser, C.CONFIG_SECTION, old, Exception)
210 except (configparser.NoSectionError, configparser.NoOptionError): 209 except (configparser.NoSectionError, configparser.NoOptionError):
211 pass 210 pass
212 else: 211 else:
213 print(("\n/!\\ Use of {old} is deprecated, please use {new} instead\n" 212 print(("\n/!\\ Use of {old} is deprecated, please use {new} instead\n"
214 .format(old=old, new=new))) 213 .format(old=old, new=new)))
215 config_parser.set(CONFIG_SECTION, new, value) 214 config_parser.set(C.CONFIG_SECTION, new, value)
216 215
217 216
218 @implementer(IServiceMaker, IPlugin) 217 @implementer(IServiceMaker, IPlugin)
219 class LiberviaMaker(object): 218 class LiberviaMaker(object):
220 219