diff options
Diffstat (limited to 'talermerchantdemos')
-rw-r--r-- | talermerchantdemos/blog/blog.py | 10 | ||||
-rw-r--r-- | talermerchantdemos/cli.py | 19 | ||||
-rw-r--r-- | talermerchantdemos/donations/donations.py | 11 | ||||
-rw-r--r-- | talermerchantdemos/landing/landing.py | 7 | ||||
-rw-r--r-- | talermerchantdemos/survey/survey.py | 17 |
5 files changed, 47 insertions, 17 deletions
diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py index 952f63c..90ef3b9 100644 --- a/talermerchantdemos/blog/blog.py +++ b/talermerchantdemos/blog/blog.py @@ -24,6 +24,7 @@ import traceback import uuid import base64 import flask +import uwsgi from flask import request, url_for from flask_babel import Babel from flask_babel import refresh @@ -83,12 +84,13 @@ app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1, x_prefix=1) app.debug = True app.secret_key = base64.b64encode(os.urandom(64)).decode("utf-8") +logging.basicConfig() LOGGER = logging.getLogger(__name__) -TC = TalerConfig.from_env() try: - BACKEND_BASE_URL = TC["frontends"]["backend"].value_string(required=True) - CURRENCY = TC["taler"]["currency"].value_string(required=True) - APIKEY = TC["frontends"]["backend_apikey"].value_string(required=True) + + BACKEND_BASE_URL = uwsgi.opt["backend_url"].decode("utf-8") + CURRENCY = uwsgi.opt["currency"].decode("utf-8") + APIKEY = uwsgi.opt["apikey"].decode("utf-8") except ConfigurationError as ce: print(ce) exit(1) diff --git a/talermerchantdemos/cli.py b/talermerchantdemos/cli.py index 78f9049..48608d6 100644 --- a/talermerchantdemos/cli.py +++ b/talermerchantdemos/cli.py @@ -56,6 +56,16 @@ def handle_serve_uwsgi(config, which_shop): "--module", "talermerchantdemos.{}:app".format(which_shop), "--need-app", + "--set-ph", "backend_url={}".format( + config["frontends"]["backend"].value_string(required=True) + ), + "--set-ph", "currency={}".format( + config["taler"]["currency"].value_string(required=True) + ), + "--set-ph", "apikey={}".format( + config["frontends"]["backend_apikey"].value_string(required=True) + ), + "--module", "--cache2", "name=paid_articles,items=500" ] @@ -93,6 +103,15 @@ def handle_serve_http(config, which_shop, port=None): "--die-on-term", "--log-format", UWSGI_LOGFMT, + "--set-ph", "backend_url={}".format( + config["frontends"]["backend"].value_string(required=True) + ), + "--set-ph", "currency={}".format( + config["taler"]["currency"].value_string(required=True) + ), + "--set-ph", "apikey={}".format( + config["frontends"]["backend_apikey"].value_string(required=True) + ), "--module", "talermerchantdemos.{}:app".format(which_shop), ] diff --git a/talermerchantdemos/donations/donations.py b/talermerchantdemos/donations/donations.py index 4ba5daa..9d6e453 100644 --- a/talermerchantdemos/donations/donations.py +++ b/talermerchantdemos/donations/donations.py @@ -20,6 +20,7 @@ import base64 import logging import flask +import uwsgi from flask import request, url_for from flask_babel import Babel from flask_babel import refresh @@ -44,6 +45,7 @@ if not sys.version_info.major == 3 and sys.version_info.minor >= 6: ) sys.exit(1) +logging.basicConfig() LOGGER = logging.getLogger(__name__) BASE_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -53,11 +55,10 @@ app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1, x_prefix=1) app.debug = True app.secret_key = base64.b64encode(os.urandom(64)).decode("utf-8") -TC = TalerConfig.from_env() try: - BACKEND_BASE_URL = TC["frontends"]["backend"].value_string(required=True) - CURRENCY = TC["taler"]["currency"].value_string(required=True) - APIKEY = TC["frontends"]["backend_apikey"].value_string(required=True) + BACKEND_BASE_URL = uwsgi.opt["backend_url"].decode("utf-8") + CURRENCY = uwsgi.opt["currency"].decode("utf-8") + APIKEY = uwsgi.opt["apikey"].decode("utf-8") except ConfigurationError as ce: print(ce) exit(1) @@ -70,6 +71,8 @@ babel.localeselector(get_locale) LOGGER.info("Using translations from:" + ":".join(list(babel.translation_directories))) +LOGGER.info("backend: " + BACKEND_BASE_URL) +LOGGER.info("currency: " + CURRENCY) translations = [str(translation) for translation in babel.list_translations()] if not "en" in translations: translations.append("en") diff --git a/talermerchantdemos/landing/landing.py b/talermerchantdemos/landing/landing.py index f3280a3..5a70a05 100644 --- a/talermerchantdemos/landing/landing.py +++ b/talermerchantdemos/landing/landing.py @@ -22,6 +22,7 @@ import datetime import base64 import logging import flask +import uwsgi from flask import request, url_for from flask_babel import Babel from flask_babel import refresh @@ -53,12 +54,10 @@ app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1, x_prefix=1) app.debug = True app.secret_key = base64.b64encode(os.urandom(64)).decode("utf-8") +logging.basicConfig() LOGGER = logging.getLogger(__name__) -TC = TalerConfig.from_env() try: - BACKEND_URL = TC["frontends"]["backend"].value_string(required=True) - CURRENCY = TC["taler"]["currency"].value_string(required=True) - APIKEY = TC["frontends"]["backend_apikey"].value_string(required=True) + CURRENCY = uwsgi.opt["currency"].decode("utf-8") except ConfigurationError as ce: print(ce) exit(1) diff --git a/talermerchantdemos/survey/survey.py b/talermerchantdemos/survey/survey.py index d198ae1..347158d 100644 --- a/talermerchantdemos/survey/survey.py +++ b/talermerchantdemos/survey/survey.py @@ -20,6 +20,7 @@ import os import re import datetime import base64 +import uwsgi import logging from urllib.parse import urljoin import flask @@ -55,12 +56,13 @@ app.wsgi_app = ProxyFix(app.wsgi_app, x_host=1, x_prefix=1) app.debug = True app.secret_key = base64.b64encode(os.urandom(64)).decode("utf-8") +logging.basicConfig() LOGGER = logging.getLogger(__name__) -TC = TalerConfig.from_env() +LOGGER.setLevel(logging.DEBUG) try: - BACKEND_URL = TC["frontends"]["backend"].value_string(required=True) - CURRENCY = TC["taler"]["currency"].value_string(required=True) - APIKEY = TC["frontends"]["backend_apikey"].value_string(required=True) + BACKEND_URL = uwsgi.opt["backend_url"].decode("utf-8") + CURRENCY = uwsgi.opt["currency"].decode("utf-8") + APIKEY = uwsgi.opt["apikey"].decode("utf-8") except ConfigurationError as ce: print(ce) exit(1) @@ -72,7 +74,9 @@ babel = Babel(app) babel.localeselector(get_locale) INSTANCED_URL = urljoin(BACKEND_URL, f"instances/survey/") - +LOGGER.info("bankend URL: {url}, currency: {c}, apikey: {key}".format( + url=BACKEND_URL, c=CURRENCY, key=APIKEY +)) LOGGER.info("Using translations from:" + ":".join(list(babel.translation_directories))) translations = [str(translation) for translation in babel.list_translations()] if not "en" in translations: @@ -154,6 +158,9 @@ def index(): # @return response object of the index page. @app.route("/<lang>/", methods=["GET"]) def start(lang): + LOGGER.info("Serving main page. Currency: {}".format(CURRENCY)) + if not os.getenv("TALER_ENV_URL_MERCHANT_SUREVY"): + LOGGER.warning("TALER_ENV_URL_MERCHANT_SUREVY env variable undefined!") return flask.render_template( "survey-index.html.j2", page_title=gettext("GNU Taler Demo: Survey"), |