gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-donations] branch master updated: add missing files


From: gnunet
Subject: [GNUnet-SVN] [taler-donations] branch master updated: add missing files
Date: Thu, 29 Aug 2019 19:10:27 +0200

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

dold pushed a commit to branch master
in repository donations.

The following commit(s) were added to refs/heads/master by this push:
     new e50d7d0  add missing files
e50d7d0 is described below

commit e50d7d0a57dced455f93b0f462e48065a1f0b764
Author: Florian Dold <address@hidden>
AuthorDate: Thu Aug 29 19:10:24 2019 +0200

    add missing files
---
 .gitignore                   |  10 ----
 Makefile                     |  40 +++++++++++++++
 bin/taler-merchant-donations | 116 +++++++++++++++++++++++++++++++++++++++++++
 configure                    |  87 ++++++++++++++++++++++++++++++++
 4 files changed, 243 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index a0630f3..17e4b20 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,16 +1,6 @@
 doxygen-doc/
 .eggs/
-Makefile
-aclocal.m4
-autom4te.cache/
 compile
-config.log
-config.status
-configure
-frontend-donations.wsgi
-install-sh
-missing
-taler-merchant-donations
 talerdonations.egg-info/
 talerdonations/__pycache__/
 talerdonations/donations/__pycache__/
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1d98268
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,40 @@
+install_global=false
+-include config.mk
+
+.PHONY: all
+all:
+       @echo "This is a python project, no compilation required"
+
+.PHONY: install
+
+ifeq ($(install_global), true)
+install: install-global
+else
+install: install-local
+endif
+
+.PHONY: install-global
+install-global:
+       pip3 install .
+
+.PHONY: install-local
+install-local:
+       pip3 install . --user
+
+# run testcases
+.PHONY: check
+check:
+       @export TALER_CONFIG_FILE=talerblog/tests.conf; \
+        python3 setup.py test
+
+.PHONY: clean
+clean:
+       @echo nothing to do
+
+.PHONY: dist
+dist:
+       git archive --format=tar.gz HEAD -o taler-merchant-donations.tar.gz
+
+.PHONY: pretty
+pretty:
+       yapf -r -i talerdonations/
diff --git a/bin/taler-merchant-donations b/bin/taler-merchant-donations
new file mode 100644
index 0000000..0bda611
--- /dev/null
+++ b/bin/taler-merchant-donations
@@ -0,0 +1,116 @@
+#!/usr/bin/env python3
+
+##
+# This file is part of TALER
+# (C) 2017 INRIA
+#
+# TALER is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Affero General Public
+# License as published by the Free Software Foundation; either
+# version 3, or (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty
+# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with TALER; see the file COPYING.  If not,
+# see <http://www.gnu.org/licenses/>
+#
+#  @author Florian Dold
+#  @file Standalone script to run the donations site.
+
+import argparse
+import sys
+import os
+import site
+import logging
+from talerdonations.talerconfig import TalerConfig
+
+# No perfect match to our logging format, but good enough ...
+UWSGI_LOGFMT = "%(ltime) %(proto) %(method) %(uri) %(proto) => %(status)"
+
+
+##
+# This function interprets the 'serve-http' subcommand.
+# The effect it to launch the donations HTTP service.
+#
+# @param args command line options.
+def handle_serve_http(args):
+    port = args.port
+    if port is None:
+        port = TC["donations"]["http_port"].value_int(required=True)
+    spec = ":%d" % (port, )
+    os.execlp(
+        "uwsgi", "uwsgi", "--master", "--die-on-term", "--log-format",
+        UWSGI_LOGFMT, "--http", spec, "--module", "talerdonations"
+    )
+
+
+##
+# This function interprets the 'serve-uwsgi' subcommand.
+# The effect is to launch the donations UWSGI service.  This
+# type of service is usually used when the HTTP donations interface
+# is accessed via a reverse proxy (like Nginx, for example).
+#
+# @param command line options.
+def handle_serve_uwsgi(args):
+    del args  # pacify PEP checkers
+    serve_uwsgi = TC["donations"]["uwsgi_serve"].value_string(required=True
+                                                              ).lower()
+    params = [
+        "uwsgi", "uwsgi", "--master", "--die-on-term", "--log-format",
+        UWSGI_LOGFMT, "--module", "talerdonations"
+    ]
+    if serve_uwsgi == "tcp":
+        port = TC["donations"]["uwsgi_port"].value_int(required=True)
+        spec = ":%d" % (port, )
+        params.extend(["--socket", spec])
+    elif serve_uwsgi == "unix":
+        spec = TC["donations"]["uwsgi_unixpath"].value_filename(required=True)
+        mode = TC["donations"]["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)
+
+
+## @cond
+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()
+## @endcond
+
+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
+
+TC = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
+ARGS.func(ARGS)
diff --git a/configure b/configure
new file mode 100755
index 0000000..469bad7
--- /dev/null
+++ b/configure
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+
+set -eu
+
+usage() {
+  echo "Usage: ./configure [OPTION]"
+  echo
+  echo "Configuration:"
+  echo "  -h, --help              display this help and exit"
+  echo
+  echo "Installation directories:"
+  echo "  --destination=[local|global] install Python package locally or 
globally"
+}
+
+
+# -allow a command to fail with !’s side effect on errexit
+# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
+! getopt --test > /dev/null
+if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
+    echo 'getopt not available'
+    exit 1
+fi
+
+LONGOPTS=destination:,help
+OPTIONS=h
+
+! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- 
"$@")
+if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+    # e.g. return value is 1
+    #  then getopt has complained about wrong arguments to stdout
+    exit 2
+fi
+
+# read getopt’s output this way to handle the quoting right:
+eval set -- "$PARSED"
+
+destination="local"
+
+while true; do
+    case "$1" in
+      --destination)
+        destination="$2"
+        shift 2
+        ;;
+      -h|--help)
+        usage
+        exit 1
+        ;;
+      --)
+        shift
+        break
+        ;;
+      *)
+        echo "Programming error"
+        exit 3
+        ;;
+    esac
+done
+
+case "$destination" in
+  local)
+    install_global=false
+    ;;
+  global)
+    install_global=true
+    ;;
+  *)
+    echo "Destination (--destination) must be 'local' or 'global', paths are 
not allowed."
+    exit 3
+    ;;
+esac
+
+cat << EOF > config.mk
+# this file is autogenerated by ./configure
+install_global=$install_global
+EOF
+
+
+if ! python3 --version &>/dev/null; then
+  echo 'Error: python3 missing'
+  exit 1
+fi
+
+if ! pip3 --version &>/dev/null; then
+  echo 'Error: pip3 missing'
+  exit 1
+fi

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



reply via email to

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