summaryrefslogtreecommitdiff
path: root/talermerchantdemos/survey
diff options
context:
space:
mode:
authorMS <ms@taler.net>2022-10-25 15:45:47 +0200
committerMS <ms@taler.net>2022-10-25 15:45:47 +0200
commit01c05e45267f0faeecc3f1d315d9b88b95437372 (patch)
treec408ccb4748e2b9d3bdf0987d04b7f15535e811b /talermerchantdemos/survey
parentd82e8d5a1dc363373268fa0a0342f98c2812fd13 (diff)
downloadtaler-merchant-demos-01c05e45267f0faeecc3f1d315d9b88b95437372.tar.gz
taler-merchant-demos-01c05e45267f0faeecc3f1d315d9b88b95437372.tar.bz2
taler-merchant-demos-01c05e45267f0faeecc3f1d315d9b88b95437372.zip
fix -c option
Python modules used to ignore it by completely reloading the config from a default location. CLI now passes values to them.
Diffstat (limited to 'talermerchantdemos/survey')
-rw-r--r--talermerchantdemos/survey/survey.py17
1 files changed, 12 insertions, 5 deletions
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"),