websauna.system.devop.cmdline module

Helper functions to initializer Websauna framework for command line applications.

websauna.system.devop.cmdline.get_wsgi_app(config_uri, defaults)[source]

Return a Websauna WSGI application given a configuration uri.

Parameters
  • config_uri (str) – Configuration uri, i.e.: websauna/conf/development.ini.

  • defaults (dict) – Extra options to be passed to the app.

Return type

Router

Returns

A Websauna WSGI Application

websauna.system.devop.cmdline.init_websauna(config_uri, sanity_check=False, console_app=False, extra_options=None)[source]

Initialize Websauna WSGI application for a command line oriented script.

Example:

import sys
from websauna.system.devop.cmdline import init_websauna

config_uri = sys.argv[1]
request = init_websauna(config_uri)
Parameters
  • config_uri (str) – Path to config INI file

  • sanity_check (bool) – Perform database sanity check on start

  • console_app (bool) – Set true to setup console-mode logging. See setup_console_logging()

  • extra_options (Optional[dict]) – Passed through bootstrap() and is available as websauna.system.Initializer.global_options.

Return type

Request

Returns

Faux Request object pointing to a site root, having registry and every configured.

websauna.system.devop.cmdline.init_websauna_script_env(config_uri)[source]

Initialize Websauna WSGI application for a IPython notebook.

Parameters

config_uri (str) – Path to config INI file

Return type

dict

Returns

Dictionary of shell variables

websauna.system.devop.cmdline.initializer_from_app(app)[source]

Return the initializer for the given app.

Parameters

app (Router) – Websauna WSGI application

Return type

Initializer

Returns

Websauna Initializer

websauna.system.devop.cmdline.prepare_config_uri(config_uri)[source]

Make sure a configuration uri has the prefix ws://.

Parameters

config_uri (str) – Configuration uri, i.e.: websauna/conf/development.ini

Return type

str

Returns

Configuration uri with the prefix ws://.

websauna.system.devop.cmdline.setup_console_logging(log_level=None)[source]

Setup console logging.

Aimed to give easy sane defaults for logging in command line applications.

Don’t use logging settings from INI, but use hardcoded defaults.

websauna.system.devop.cmdline.setup_logging(config_uri, disable_existing_loggers=False)[source]

Include-aware Python logging setup from INI config file.