gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-survey] branch master updated: linting the luncher


From: gnunet
Subject: [GNUnet-SVN] [taler-survey] branch master updated: linting the luncher
Date: Tue, 05 Dec 2017 21:17:52 +0100

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

marcello pushed a commit to branch master
in repository survey.

The following commit(s) were added to refs/heads/master by this push:
     new b227d20  linting the luncher
b227d20 is described below

commit b227d20e6d4e54cbee5ba4c09f83a352f0e3909d
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Dec 5 21:17:42 2017 +0100

    linting the luncher
---
 taler-merchant-survey.in | 79 ++++++++++++++++++++++++------------------------
 1 file changed, 40 insertions(+), 39 deletions(-)

diff --git a/taler-merchant-survey.in b/taler-merchant-survey.in
index 11135cd..afe8b29 100644
--- a/taler-merchant-survey.in
+++ b/taler-merchant-survey.in
@@ -9,49 +9,47 @@ import argparse
 import sys
 import os
 import site
+import logging
+from talersurvey.talerconfig import TalerConfig
 
 
 os.environ.setdefault("TALER_PREFIX", "@prefix@")
 site.addsitedir("%s/lib/python%d.%d/site-packages" % (
-    "@prefix@", 
+    "@prefix@",
     sys.version_info.major,
     sys.version_info.minor))
 
-from talersurvey.talerconfig import TalerConfig
-import logging
-logger = logging.getLogger(__name__)
-
+TC = TalerConfig.from_file(os.environ.get("TALER_CONFIG_FILE"))
+LOGGER = logging.getLogger(__name__)
 # No perfect match to our logging format, but good enough ...
-uwsgi_logfmt = "%(ltime) %(proto) %(method) %(uri) %(proto) => %(status)"
+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)
+        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()
+              "--master",
+              "--die-on-term",
+              "--log-format", UWSGI_LOGFMT,
+              "--http", spec,
+              "--wsgi-file", "@prefix@/share/taler/frontend-survey.wsgi")
+
+def handle_serve_uwsgi():
+    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"]
+              "--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)
+        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)
+        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)
@@ -60,24 +58,27 @@ def handle_serve_uwsgi(args):
 
 
 
-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()
+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-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)
+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()
+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
+if ARGS.config is not None:
+    os.environ["TALER_CONFIG_FILE"] = ARGS.config
 
-args.func(args)
+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]