gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-survey] 01/01: Adding Makefile/setup.py/taler-mercha


From: gnunet
Subject: [GNUnet-SVN] [taler-survey] 01/01: Adding Makefile/setup.py/taler-merchant-survey.
Date: Mon, 20 Nov 2017 12:32:40 +0100

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository survey.

commit d54238ed5b32ce10ea9e42ef4d8bc3feba6925b7
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Nov 20 12:31:59 2017 +0100

    Adding Makefile/setup.py/taler-merchant-survey.
---
 Makefile.in              | 53 +++++++++++++++++++++++++++++++
 setup.py                 | 27 ++++++++++++++++
 taler-merchant-survey.in | 83 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 163 insertions(+)

diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..eb34733
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,53 @@
+INSTALL = install
+INSTALL_PROGRAM = $(INSTALL)
+INSTALL_DATA = $(INSTALL) -m 644
+prefix = @prefix@
+srcdir = @srcdir@
+
+script_templates = taler-merchant-survey frontend-survey.wsgi
+templates = Makefile $(script_templates)
+
+edit = sed -e 's|@address@hidden|$(prefix)|g'
+
+.PHONY: all
+all: $(templates)
+       cd talersurvey/survey/static/web-common && make && cd -
+
+Makefile: Makefile.in
+       ./config.status $@
+
+$(script_templates): %: Makefile %.in
+       rm -f $@ address@hidden
+       $(edit) '$(srcdir)/address@hidden' >address@hidden
+       mv address@hidden $@
+
+
+.PHONY: install-data
+install-data: $(templates)
+       @$(INSTALL_DATA) -Dt $(prefix)/share/taler/ frontend-survey.wsgi
+
+#      @test -n "$$(ls -A talerbank/app/static/web-common/)" || \
+#      (echo "please check out git submodules"; exit 1)
+
+
+
+# link package under prefix to source tree
+.PHONY: devinstall
+devinstall: $(templates) install-data
+       @pip3 install -e . --install-option="address@hidden@"
+
+
+# install into prefix
+.PHONY: install
+install: $(templates) install-data
+       @pip3 install . --install-option="address@hidden@"
+       @# force update when sources changed
+       @pip3 install . --install-option="address@hidden@" --upgrade --no-deps
+       cd talersurvey/survey/static/web-common && make install && cd -
+
+# run testcases
+.PHONY: check
+check:
+       @export TALER_CONFIG_FILE=./talersurvey/tests.conf; \
+        export address@hidden@/lib/python3.5/site-packages; \
+        python3 ./talersurvey/tests.py
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..6e92670
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,27 @@
+from setuptools import setup, find_packages
+
+setup(name='talersurvey',
+      version='0.0',
+      description='Example survey site for GNU Taler',
+      url='git://taler.net/survey',
+      author='Marcello Stanisci',
+      author_email='address@hidden',
+      license='GPL',
+      packages=find_packages(),
+      install_requires=["Flask>=0.10"],
+      package_data={
+          '':[
+              "survey/templates/*.html",
+              "survey/static/*.svg",
+              "survey/static/*.css",
+              "survey/static/*.js",
+              "survey/static/*.js.tar.gz",
+              "survey/static/web-common/*.png",
+              "survey/static/web-common/*.css",
+              "survey/static/web-common/*.js",
+              "survey/static/web-common/*.js.tar.gz",
+              "survey/static/web-common/*.html",
+      ]
+      },
+      scripts=['taler-merchant-survey'],
+      zip_safe=False)
diff --git a/taler-merchant-survey.in b/taler-merchant-survey.in
new file mode 100644
index 0000000..11135cd
--- /dev/null
+++ b/taler-merchant-survey.in
@@ -0,0 +1,83 @@
+#!/usr/bin/env python3
+
+"""
+Stand-alone script to manage the GNU Taler
+survey frontend.
+"""
+
+import argparse
+import sys
+import os
+import site
+
+
+os.environ.setdefault("TALER_PREFIX", "@prefix@")
+site.addsitedir("%s/lib/python%d.%d/site-packages" % (
+    "@prefix@", 
+    sys.version_info.major,
+    sys.version_info.minor))
+
+from talersurvey.talerconfig import TalerConfig
+import logging
+logger = logging.getLogger(__name__)
+
+# No perfect match to our logging format, but good enough ...
+uwsgi_logfmt = "%(ltime) %(proto) %(method) %(uri) %(proto) => %(status)"
+
+def handle_serve_http(args):
+    tc = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
+    port = args.port
+    if port is None:
+        port = tc["survey"]["http_port"].value_int(required=True)
+    spec = ":%d" % (port,)
+    os.execlp("uwsgi", "uwsgi",
+            "--master",
+            "--die-on-term",
+            "--log-format", uwsgi_logfmt,
+            "--http", spec,
+            "--wsgi-file", "@prefix@/share/taler/frontend-survey.wsgi")
+
+def handle_serve_uwsgi(args):
+    tc = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
+    serve_uwsgi = 
tc["survey"]["uwsgi_serve"].value_string(required=True).lower()
+    params = ["uwsgi", "uwsgi",
+        "--master",
+        "--die-on-term",
+        "--log-format", uwsgi_logfmt,
+        "--wsgi-file", "@prefix@/share/taler/frontend-survey.wsgi"]
+    if serve_uwsgi == "tcp":
+        port = tc["survey"]["uwsgi_port"].value_int(required=True)
+        spec = ":%d" % (port,)
+        params.extend(["--socket", spec])
+    elif serve_uwsgi == "unix":
+        spec = tc["survey"]["uwsgi_unixpath"].value_filename(required=True)
+        mode = 
tc["survey"]["uwsgi_unixpath_mode"].value_filename(required=True)
+        params.extend(["--socket", spec])
+        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)
+
+
+
+parser = argparse.ArgumentParser()
+parser.set_defaults(func=None)
+parser.add_argument('--config', '-c', help="configuration file to use", 
metavar="CONFIG", type=str, dest="config", default=None)
+sub = parser.add_subparsers()
+
+p = sub.add_parser('serve-http', help="Serve over HTTP")
+p.add_argument("--port", "-p", dest="port", type=int, default=None, 
metavar="PORT")
+p.set_defaults(func=handle_serve_http)
+
+p = sub.add_parser('serve-uwsgi', help="Serve over UWSGI")
+p.set_defaults(func=handle_serve_uwsgi)
+
+args = parser.parse_args()
+if getattr(args, 'func', None) is None:
+    parser.print_help()
+    sys.exit(1)
+
+if args.config is not None:
+    os.environ["TALER_CONFIG_FILE"] = args.config
+
+args.func(args)

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]