From 46ea792c5e0bd2c135b2f1fa0140787c57131d2d Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 12 Aug 2020 08:30:03 +0200 Subject: [PATCH] import tiramisu3 first --- src/risotto/config.py | 2 -- src/risotto/controller.py | 4 ++-- src/risotto/dispatcher.py | 9 ++++++--- src/risotto/http.py | 5 ++++- src/risotto/message.py | 11 ++++++++--- src/risotto/register.py | 5 ++++- src/risotto/remote.py | 2 +- 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/risotto/config.py b/src/risotto/config.py index d6cd782..0f7d46c 100644 --- a/src/risotto/config.py +++ b/src/risotto/config.py @@ -15,7 +15,6 @@ DB_ADDRESS = environ.get('DB_ADDRESS', 'localhost') MESSAGE_PATH = environ.get('MESSAGE_PATH', '/root/risotto-message/messages') SQL_DIR = environ.get('SQL_DIR', './sql') CACHE_ROOT_PATH = environ.get('CACHE_ROOT_PATH', '/var/cache/risotto') -SRV_SEED_PATH = environ.get('SRV_SEED_PATH', '/srv/seed') def dsn_factory(database, user, password, address=DB_ADDRESS): @@ -36,7 +35,6 @@ def get_config(): 'check_role': True, 'admin_user': DEFAULT_USER, 'sql_dir': SQL_DIR}, - 'source': {'root_path': SRV_SEED_PATH}, 'cache': {'root_path': CACHE_ROOT_PATH}, 'servermodel': {'internal_source': 'internal', 'internal_distribution': 'last', diff --git a/src/risotto/controller.py b/src/risotto/controller.py index 0b136d7..cc0a67c 100644 --- a/src/risotto/controller.py +++ b/src/risotto/controller.py @@ -24,7 +24,7 @@ class Controller: if args: raise ValueError(_(f'the URI "{uri}" can only be called with keyword arguments')) if module not in self.risotto_modules: - return await remote.remove_call(module, + return await remote.remote_call(module, version, message, kwargs) @@ -44,7 +44,7 @@ class Controller: if args: raise ValueError(_(f'the URI "{uri}" can only be published with keyword arguments')) if module not in self.risotto_modules: - await remote.remove_call(module, + await remote.remote_call(module, version, submessage, kwargs) diff --git a/src/risotto/dispatcher.py b/src/risotto/dispatcher.py index 2572a88..92c400b 100644 --- a/src/risotto/dispatcher.py +++ b/src/risotto/dispatcher.py @@ -1,4 +1,7 @@ -from tiramisu import Config +try: + from tiramisu3 import Config +except: + from tiramisu import Config from traceback import print_exc from copy import copy from typing import Dict, Callable, List, Optional @@ -10,7 +13,7 @@ from .logger import log from .config import get_config from .context import Context from . import register -from .remote import Remote +#from .remote import Remote import asyncpg @@ -183,7 +186,7 @@ class PublishDispatcher: class Dispatcher(register.RegisterDispatcher, - Remote, +# Remote, CallDispatcher, PublishDispatcher): """ Manage message (call or publish) diff --git a/src/risotto/http.py b/src/risotto/http.py index c7199da..cbfdac7 100644 --- a/src/risotto/http.py +++ b/src/risotto/http.py @@ -1,7 +1,10 @@ from aiohttp.web import Application, Response, get, post, HTTPBadRequest, HTTPInternalServerError, HTTPNotFound from json import dumps from traceback import print_exc -from tiramisu import Config, default_storage +try: + from tiramisu3 import Config, default_storage +except: + from tiramisu import Config, default_storage from .dispatcher import dispatcher diff --git a/src/risotto/message.py b/src/risotto/message.py index da45424..da6dea6 100644 --- a/src/risotto/message.py +++ b/src/risotto/message.py @@ -2,9 +2,14 @@ from os import listdir from os.path import join, basename, dirname, isfile from glob import glob from gettext import translation -from tiramisu import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, SymLinkOption, FloatOption, \ - Calculation, Params, ParamOption, ParamValue, calc_value, calc_value_property_help, \ - groups, Option +try: + from tiramisu3 import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, \ + SymLinkOption, FloatOption, Calculation, Params, ParamOption, \ + ParamValue, calc_value, calc_value_property_help, groups, Option +except: + from tiramisu import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, \ + SymLinkOption, FloatOption, Calculation, Params, ParamOption, \ + ParamValue, calc_value, calc_value_property_help, groups, Option from yaml import load, SafeLoader diff --git a/src/risotto/register.py b/src/risotto/register.py index 3a5715e..1f16f4a 100644 --- a/src/risotto/register.py +++ b/src/risotto/register.py @@ -1,4 +1,7 @@ -from tiramisu import Config +try: + from tiramisu3 import Config +except: + from tiramisu import Config from inspect import signature from typing import Callable, Optional import asyncpg diff --git a/src/risotto/remote.py b/src/risotto/remote.py index c42a7a8..a3c2aad 100644 --- a/src/risotto/remote.py +++ b/src/risotto/remote.py @@ -31,7 +31,7 @@ class Remote: self.submodules[module] = json return Config(self.submodules[module]) - async def remove_call(self, + async def remote_call(self, module: str, version: str, submessage: str,