diff --git a/src/risotto/config.py b/src/risotto/config.py index 570707f..bae6488 100644 --- a/src/risotto/config.py +++ b/src/risotto/config.py @@ -65,6 +65,18 @@ if 'CELERYRISOTTO_DB_USER' in environ: CELERYRISOTTO_DB_USER = environ['CELERYRISOTTO_DB_USER'] else: CELERYRISOTTO_DB_USER = config.get('CELERYRISOTTO_DB_USER', None) +if 'LEMUR_DB_NAME' in environ: + LEMUR_DB_NAME = environ['LEMUR_DB_NAME'] +else: + LEMUR_DB_NAME = config.get('LEMUR_DB_NAME', None) +if 'LEMUR_DB_PASSWORD' in environ: + LEMUR_DB_PASSWORD = environ['LEMUR_DB_PASSWORD'] +else: + LEMUR_DB_PASSWORD = config.get('LEMUR_DB_PASSWORD', None) +if 'LEMUR_DB_USER' in environ: + LEMUR_DB_USER = environ['LEMUR_DB_USER'] +else: + LEMUR_DB_USER = config.get('LEMUR_DB_USER', None) if 'DB_ADDRESS' in environ: DB_ADDRESS = environ['DB_ADDRESS'] else: @@ -141,7 +153,8 @@ def dsn_factory(database, user, password, address=DB_ADDRESS): _config = {'database': {'dsn': dsn_factory(RISOTTO_DB_NAME, RISOTTO_DB_USER, RISOTTO_DB_PASSWORD), 'tiramisu_dsn': dsn_factory(TIRAMISU_DB_NAME, TIRAMISU_DB_USER, TIRAMISU_DB_PASSWORD), - 'celery_dsn': dsn_factory(CELERYRISOTTO_DB_NAME, CELERYRISOTTO_DB_USER, CELERYRISOTTO_DB_PASSWORD) + 'celery_dsn': dsn_factory(CELERYRISOTTO_DB_NAME, CELERYRISOTTO_DB_USER, CELERYRISOTTO_DB_PASSWORD), + 'lemur_dns': dsn_factory(LEMUR_DB_NAME, LEMUR_DB_USER, LEMUR_DB_PASSWORD), }, 'http_server': {'port': RISOTTO_PORT, 'default_user': DEFAULT_USER, diff --git a/src/risotto/dispatcher.py b/src/risotto/dispatcher.py index 607a90f..ddda87e 100644 --- a/src/risotto/dispatcher.py +++ b/src/risotto/dispatcher.py @@ -475,6 +475,8 @@ class Dispatcher(register.RegisterDispatcher, ) # notification if function_obj.get('notification'): + if returns is None: + raise Exception(_(f'function "{function_obj["full_module_name"]}.{function_obj["function"].__name__}" must returns something for {function_obj["notification"]}!')) notif_version, notif_message = function_obj['notification'].split('.', 1) if not isinstance(returns, list): send_returns = [returns] diff --git a/src/risotto/http.py b/src/risotto/http.py index 5b235f2..151f6e5 100644 --- a/src/risotto/http.py +++ b/src/risotto/http.py @@ -23,9 +23,13 @@ extra_statics = {} def create_context(request): risotto_context = Context() - risotto_context.username = request.match_info.get('username', - get_config()['http_server']['default_user'], - ) + if 'username' in dict(request.match_info): + username = request.match_info['username'] + elif 'username' in request.headers: + username = request.headers['username'] + else: + username = get_config()['http_server']['default_user'] + risotto_context.username = username return risotto_context diff --git a/src/risotto/logger.py b/src/risotto/logger.py index 2c168d7..2ee09aa 100644 --- a/src/risotto/logger.py +++ b/src/risotto/logger.py @@ -192,7 +192,7 @@ class Logger: await connection.execute(sql, risotto_context.start_id, datetime.now(), - err, + err[:254], LEVELS.index('Failure'), ) diff --git a/src/risotto/register.py b/src/risotto/register.py index b08a1b3..ed01119 100644 --- a/src/risotto/register.py +++ b/src/risotto/register.py @@ -107,6 +107,7 @@ class RegisterDispatcher: version = obj['version'] if version not in self.messages: self.messages[version] = {} + obj['message'] = tiramisu_message self.messages[version][tiramisu_message] = obj def get_function_args(self,