Mercurial > libervia-web
diff twisted/plugins/libervia_server.py @ 1518:eb00d593801d
refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 16:49:28 +0200 |
parents | 106bae41f5c8 |
children | a44f77559279 |
line wrap: on
line diff
--- a/twisted/plugins/libervia_server.py Thu Jun 01 21:42:02 2023 +0200 +++ b/twisted/plugins/libervia_server.py Fri Jun 02 16:49:28 2023 +0200 @@ -33,13 +33,13 @@ import re import os.path -import libervia -import sat +import libervia.web +import libervia.backend -from libervia.server.constants import Const as C +from libervia.web.server.constants import Const as C -from sat.core.i18n import _ -from sat.tools import config +from libervia.backend.core.i18n import _ +from libervia.backend.tools import config from zope.interface import implementer @@ -51,22 +51,22 @@ RE_VER_POST = re.compile(r"\.post[0-9]+") -if RE_VER_POST.sub("", libervia.__version__) != RE_VER_POST.sub("", sat.__version__): +if RE_VER_POST.sub("", libervia.web.__version__) != RE_VER_POST.sub("", libervia.backend.__version__): import sys sys.stderr.write( - """sat module version ({sat_version}) and {current_app} version ({current_version}) mismatch + """libervia.backend module version ({sat_version}) and {current_app} version ({current_version}) mismatch -sat module is located at {sat_path} +libervia.backend module is located at {sat_path} libervia module is located at {libervia_path} Please be sure to have the same version running """.format( - sat_version=sat.__version__, + sat_version=libervia.backend.__version__, current_app=C.APP_NAME, - current_version=libervia.__version__, - sat_path=os.path.dirname(sat.__file__), - libervia_path=os.path.dirname(libervia.__file__), + current_version=libervia.web.__version__, + sat_path=os.path.dirname(libervia.backend.__file__), + libervia_path=os.path.dirname(libervia.web.__file__), ) ) sys.stderr.flush() @@ -101,7 +101,7 @@ DATA_DIR_DEFAULT = '' # prefix used for environment variables ENV_PREFIX = "LIBERVIA_" -# options which are in sat.conf and on command line, +# options which are in libervia.conf and on command line, # see https://twistedmatrix.com/documents/current/api/twisted.python.usage.Options.html OPT_PARAMETERS_BOTH = [['connection_type', 't', 'https', _("'http', 'https' or 'both' " "(to launch both servers)."), @@ -135,7 +135,7 @@ _('Number of tries to connect to bridge before giving up'), int], ] -# Options which are in sat.conf only +# Options which are in libervia.conf only OPT_PARAMETERS_CFG = [ ["empty_password_allowed_warning_dangerous_list", None, "", None], ["vhosts_dict", None, {}, None], @@ -158,7 +158,7 @@ """Method to initialise global modules""" # XXX: We need to configure logs before any log method is used, # so here is the best place. - from sat.core import log_config + from libervia.backend.core import log_config log_config.sat_configure(C.LOG_BACKEND_TWISTED, C, backend_data=options) @@ -205,7 +205,7 @@ def handleDeprecated(self, config_parser): """display warning and/or change option when a deprecated option if found - param config_parser(ConfigParser): read ConfigParser instance for sat.conf + param config_parser(ConfigParser): read ConfigParser instance for libervia.conf """ replacements = (("ssl_certificate", "tls_certificate"),) for old, new in replacements: @@ -231,7 +231,7 @@ gireactor.install() for opt in OPT_PARAMETERS_BOTH: # FIXME: that's a ugly way to get unicode in Libervia - # from command line or sat.conf + # from command line or libervia.conf # we should move to argparse and handle options this properly try: coerce_cb = opt[4] @@ -242,9 +242,9 @@ print(f"FIXME: {opt[0]} is not unicode") options[opt[0]] = options[opt[0]].decode("utf-8") initialise(options.parent) - from libervia.server import server + from libervia.web.server import server - return server.Libervia(options) + return server.LiberviaWeb(options) # affectation to some variable is necessary for twisted introspection to work