summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-09-06 11:20:15 +0200
committerChristian Grothoff <christian@grothoff.org>2020-09-06 11:20:15 +0200
commitb0f3d60fec149ffee23872bd0e9290bebdf679e3 (patch)
tree0a0bd752ac82472fdfd4e6fb20d7420e32b3d639
parent30bad63dacae699e5256fd6d6e27a968ad6cce30 (diff)
parent9cf423b539c24bf2c210f5a5dd997664f88727d6 (diff)
downloadtaler-merchant-demos-b0f3d60fec149ffee23872bd0e9290bebdf679e3.tar.gz
taler-merchant-demos-b0f3d60fec149ffee23872bd0e9290bebdf679e3.tar.bz2
taler-merchant-demos-b0f3d60fec149ffee23872bd0e9290bebdf679e3.zip
merge
-rw-r--r--README.md18
-rwxr-xr-xbin/taler-merchant-demos35
-rwxr-xr-xsetup.py8
-rw-r--r--talermerchantdemos/blog/blog.py21
-rw-r--r--talermerchantdemos/donations/donations.py18
-rw-r--r--talermerchantdemos/survey/survey.py19
6 files changed, 83 insertions, 36 deletions
diff --git a/README.md b/README.md
index cb5bba6..967bafa 100644
--- a/README.md
+++ b/README.md
@@ -6,19 +6,19 @@ Step 1: `cd` into the directory:<br/>
> ```$ cd taler-merchant-demos```
<br/>
-Step 2: configure it using:<br/>
+Step 2: Ensure Python3.5 or above is installed using a command like:<br/>
-> ```$ ./configure --destination=local```
+> ```$ sudo apt install python3.8 -y```
<br/>
-Step 3: Ensure Python3.5 or above is installed using a command like:<br/>
+Step 3: Ensure Python3 Pip is installed:<br/>
-> ```$ sudo apt install python3.8 -y```
+> ```$ sudo apt install python3-pip -y```
<br/>
-Step 4: Ensure Python3 Pip is installed:<br/>
+Step 4: configure it using:<br/>
-> ```$ sudo apt install python3-pip -y```
+> ```$ ./configure --destination=local```
Step 5: Install UWSGI<br>
*NOTE: DO NOT INSTALL USING PIP2 (on my system, that is what the pip command uses) - INSTALL IT USING PIP3*
@@ -29,9 +29,13 @@ Step 5: Install UWSGI<br>
Step 6: Install LXML
*NOTE: DO NOT INSTALL USING PIP2 (on my system, that is what the pip command uses) - INSTALL IT USING PIP3*
-> ```pip3 install lxml```
+> ```$ pip3 install lxml```
<br>
+## Quick Install for the dependencies
+Here's one command to automatically install all dependencies at once:
+> ```$ sudo apt install python3.8 python3-pip -y; pip3 install lxml uwsgi; ./configure --destination=local```
+
## Configuring the demo
*This is just how I did it, and not the main method of doing it*
diff --git a/bin/taler-merchant-demos b/bin/taler-merchant-demos
index cf56d81..7ed69d7 100755
--- a/bin/taler-merchant-demos
+++ b/bin/taler-merchant-demos
@@ -27,7 +27,7 @@ import argparse
import sys
import os
import site
-from taler.util.talerconfig import TalerConfig
+from taler.util.talerconfig import TalerConfig, ConfigurationError
LOGGER = logging.getLogger(__name__)
# No perfect match to our logging format, but good enough ...
@@ -60,7 +60,11 @@ def handle_serve_uwsgi(config, whichShop):
params.extend(["--chmod-socket="+mode])
os.makedirs(os.path.dirname(spec), exist_ok=True)
logging.info("launching uwsgi with argv %s", params[1:])
- os.execlp(*params)
+ try:
+ os.execlp(*params)
+ except:
+ sys.stderr.write("Failed to start uwsgi. Please make sure to install uwsgi for Python3.")
+ sys.exit(1)
##
# This function interprets the 'serve-http' subcommand.
@@ -69,15 +73,22 @@ def handle_serve_uwsgi(config, whichShop):
# @param args command line options.
def handle_serve_http(config, whichShop, port=None):
if port is None:
- port = config[whichShop]["http_port"].value_int(required=True)
+ try:
+ port = config[whichShop]["http_port"].value_int(required=True)
+ except ConfigurationError as ce:
+ print(ce)
+ exit(1)
spec = ":%d" % (port,)
- os.execlp("uwsgi", "uwsgi",
- "--master",
- "--die-on-term",
- "--log-format", UWSGI_LOGFMT,
- "--http", spec,
- "--need-app",
- "--module", "talermerchantdemos.{}:app".format(whichShop))
+ try:
+ os.execlp("uwsgi", "uwsgi",
+ "--master",
+ "--die-on-term",
+ "--log-format", UWSGI_LOGFMT,
+ "--http", spec,
+ "--module", "talermerchantdemos.{}:app".format(whichShop))
+ except:
+ sys.stderr.write("Failed to start uwsgi. Please make sure to install uwsgi for Python3.")
+ sys.exit(1)
@click.command("Global shop launcher")
@click.option("--config", help="Configuration file", required=False)
@@ -94,7 +105,7 @@ def demos(config, serve_http, port, serve_uwsgi, which_shop):
config_obj = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
if serve_http: # port was given
handle_serve_http(config_obj, which_shop, port)
- return
- handle_serve_uwsgi(config_obj, which_shop)
+ else:
+ handle_serve_uwsgi(config_obj, which_shop)
demos()
diff --git a/setup.py b/setup.py
index 07bd8a7..deeba73 100755
--- a/setup.py
+++ b/setup.py
@@ -1,12 +1,12 @@
from setuptools import setup, find_packages
setup(name='talermerchantdemos',
- version='0.6.0pre1',
+ version='0.8.0',
description='Example blog/donations/survey sites for GNU Taler',
url='git://taler.net/taler-merchant-demos',
- author=['Marcello Stanisci', 'Florian Dold'],
- author_email=['ms@taler.net', 'florian@dold.me'],
- license='GPL',
+ author=['Marcello Stanisci', 'Florian Dold', 'Christian Grothoff'],
+ author_email=['ms@taler.net', 'florian@dold.me', 'cg@taler.net'],
+ license='AGPL',
packages=find_packages(),
install_requires=["Flask>=0.10",
"beautifulsoup4",
diff --git a/talermerchantdemos/blog/blog.py b/talermerchantdemos/blog/blog.py
index c024380..c54a8d6 100644
--- a/talermerchantdemos/blog/blog.py
+++ b/talermerchantdemos/blog/blog.py
@@ -25,20 +25,31 @@ import uuid
import base64
import flask
import time
+import sys
from urllib.parse import urljoin, urlencode, urlparse
-from taler.util.talerconfig import TalerConfig
+from taler.util.talerconfig import TalerConfig, ConfigurationError
from ..blog.content import ARTICLES, get_article_file, get_image_file
from talermerchantdemos.httpcommon import backend_get, backend_post
+if not sys.version_info.major == 3 and sys.version_info.minor >= 6:
+ print("Python 3.6 or higher is required.")
+ print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor))
+ sys.exit(1)
+
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
-app = flask.Flask(__name__, template_folder=BASE_DIR)
+app = flask.Flask(__name__, template_folder=BASE_DIR, static_folder=BASE_DIR + '/../static/')
app.secret_key = base64.b64encode(os.urandom(64)).decode("utf-8")
LOGGER = logging.getLogger(__name__)
TC = TalerConfig.from_env()
-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)
+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)
+except ConfigurationError as ce:
+ print(ce)
+ exit(1)
ARTICLE_AMOUNT = CURRENCY + ":0.5"
BACKEND_URL = urljoin(BACKEND_BASE_URL, "instances/blog/")
diff --git a/talermerchantdemos/donations/donations.py b/talermerchantdemos/donations/donations.py
index afca27c..7d4c9c6 100644
--- a/talermerchantdemos/donations/donations.py
+++ b/talermerchantdemos/donations/donations.py
@@ -24,9 +24,15 @@ import os
import time
import traceback
import urllib
-from taler.util.talerconfig import TalerConfig
+from taler.util.talerconfig import TalerConfig, ConfigurationError
from urllib.parse import urljoin
from ..httpcommon import backend_post, backend_get
+import sys
+
+if not sys.version_info.major == 3 and sys.version_info.minor >= 6:
+ print("Python 3.6 or higher is required.")
+ print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor))
+ sys.exit(1)
LOGGER = logging.getLogger(__name__)
@@ -37,9 +43,13 @@ app.debug = True
app.secret_key = base64.b64encode(os.urandom(64)).decode("utf-8")
TC = TalerConfig.from_env()
-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)
+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)
+except ConfigurationError as ce:
+ print(ce)
+ exit(1)
app.config.from_object(__name__)
diff --git a/talermerchantdemos/survey/survey.py b/talermerchantdemos/survey/survey.py
index 25b97ad..562b817 100644
--- a/talermerchantdemos/survey/survey.py
+++ b/talermerchantdemos/survey/survey.py
@@ -24,17 +24,28 @@ import logging
from urllib.parse import urljoin
import flask
import traceback
-from taler.util.talerconfig import TalerConfig
+from taler.util.talerconfig import TalerConfig, ConfigurationError
from ..httpcommon import backend_get, backend_post
+import sys
+
+if not sys.version_info.major == 3 and sys.version_info.minor >= 6:
+ print("Python 3.6 or higher is required.")
+ print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor))
+ sys.exit(1)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
app = flask.Flask(__name__, template_folder=BASE_DIR)
app.debug = True
app.secret_key = base64.b64encode(os.urandom(64)).decode('utf-8')
TC = TalerConfig.from_env()
-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)
+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)
+except ConfigurationError as ce:
+ print(ce)
+ exit(1)
+
app.config.from_object(__name__)
LOGGER = logging.getLogger(__name__)
INSTANCED_URL = urljoin(BACKEND_URL, f"instances/survey/")