labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1606546 - in /labs/panopticon/pan-ezmlm: bin/ezmlm.apache2.wsgi bin/ezmlm.uwsgi.wsgi src/asf/wsgi/ezmlm.py uwsgi.ini
Date Sun, 29 Jun 2014 18:00:07 GMT
Author: adc
Date: Sun Jun 29 18:00:06 2014
New Revision: 1606546

URL: http://svn.apache.org/r1606546
Log:
Can now run under either uWSGI and Apache Httpd

Added:
    labs/panopticon/pan-ezmlm/bin/ezmlm.apache2.wsgi   (with props)
    labs/panopticon/pan-ezmlm/bin/ezmlm.uwsgi.wsgi   (with props)
Modified:
    labs/panopticon/pan-ezmlm/src/asf/wsgi/ezmlm.py
    labs/panopticon/pan-ezmlm/uwsgi.ini

Added: labs/panopticon/pan-ezmlm/bin/ezmlm.apache2.wsgi
URL: http://svn.apache.org/viewvc/labs/panopticon/pan-ezmlm/bin/ezmlm.apache2.wsgi?rev=1606546&view=auto
==============================================================================
--- labs/panopticon/pan-ezmlm/bin/ezmlm.apache2.wsgi (added)
+++ labs/panopticon/pan-ezmlm/bin/ezmlm.apache2.wsgi Sun Jun 29 18:00:06 2014
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+"""
+CGI based WSGI API to mailing lists.
+"""
+import os
+
+
+def application(environ, start_response):
+    if 'EZMLM_FLASK_CONFIG' not in os.environ:
+        os.environ['EZMLM_FLASK_CONFIG'] = environ['EZMLM_FLASK_CONFIG']
+
+    from asf.wsgi.ezmlm import app
+    return app.wsgi_app(environ, start_response)

Propchange: labs/panopticon/pan-ezmlm/bin/ezmlm.apache2.wsgi
------------------------------------------------------------------------------
    svn:executable = *

Added: labs/panopticon/pan-ezmlm/bin/ezmlm.uwsgi.wsgi
URL: http://svn.apache.org/viewvc/labs/panopticon/pan-ezmlm/bin/ezmlm.uwsgi.wsgi?rev=1606546&view=auto
==============================================================================
--- labs/panopticon/pan-ezmlm/bin/ezmlm.uwsgi.wsgi (added)
+++ labs/panopticon/pan-ezmlm/bin/ezmlm.uwsgi.wsgi Sun Jun 29 18:00:06 2014
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+"""
+CGI based WSGI API to mailing lists.
+"""
+import os
+
+from asf.wsgi.ezmlm import app
+
+
+def application(environ, start_response):
+    if 'EZMLM_FLASK_CONFIG' not in os.environ:
+        os.environ['EZMLM_FLASK_CONFIG'] = environ['EZMLM_FLASK_CONFIG']
+
+    return app.wsgi_app(environ, start_response)

Propchange: labs/panopticon/pan-ezmlm/bin/ezmlm.uwsgi.wsgi
------------------------------------------------------------------------------
    svn:executable = *

Modified: labs/panopticon/pan-ezmlm/src/asf/wsgi/ezmlm.py
URL: http://svn.apache.org/viewvc/labs/panopticon/pan-ezmlm/src/asf/wsgi/ezmlm.py?rev=1606546&r1=1606545&r2=1606546&view=diff
==============================================================================
--- labs/panopticon/pan-ezmlm/src/asf/wsgi/ezmlm.py (original)
+++ labs/panopticon/pan-ezmlm/src/asf/wsgi/ezmlm.py Sun Jun 29 18:00:06 2014
@@ -20,7 +20,7 @@
 CGI based WSGI API to mailing lists.
 """
 import hashlib
-from logging import getLogger
+import logging
 import os
 import time
 
@@ -30,7 +30,8 @@ from asf.utils.ezmlm import Ezmlm
 from asf.utils.wsgi import json_result, supports_etag
 
 
-log = getLogger(__name__)
+log = logging.getLogger(__name__)
+logging.basicConfig()
 
 app = flask.Flask(__name__)
 app.config.from_envvar('EZMLM_FLASK_CONFIG')
@@ -75,10 +76,14 @@ def asf_lists():
     if not os.path.exists(list_root_path):
         flask.abort(500)
 
-    modification_time = time.ctime(os.path.getmtime(list_root_path))
-    etag = hashlib.sha1(modification_time).hexdigest()
+    try:
+        modification_time = time.ctime(os.path.getmtime(list_root_path))
+        etag = hashlib.sha1(modification_time).hexdigest()
 
-    return ezmlm_list_groups(list_root_path), etag
+        return ezmlm_list_groups(list_root_path), etag
+    except Exception:
+        log.exception('Unable to provide list of mailing lists')
+        flask.abort(500)
 
 
 # noinspection PyUnusedLocal
@@ -102,10 +107,14 @@ def asf_list_subscribers(mailing_list):
     if not os.path.exists(list_path):
         flask.abort(500)
 
-    modification_time = time.ctime(os.path.getmtime(os.path.join(list_path, 'subscribers')))
-    etag = hashlib.sha1(modification_time).hexdigest()
+    try:
+        modification_time = time.ctime(os.path.getmtime(os.path.join(list_path, 'subscribers')))
+        etag = hashlib.sha1(modification_time).hexdigest()
 
-    return ezmlm_list_subscribers(list_path), etag
+        return ezmlm_list_subscribers(list_path), etag
+    except Exception:
+        log.exception('Unable to provide list of mailing subscribers of ' + mailing_list)
+        flask.abort(500)
 
 
 # noinspection PyUnusedLocal
@@ -128,7 +137,11 @@ def asf_list_moderators(mailing_list):
     if not os.path.exists(list_path):
         flask.abort(500)
 
-    return ezmlm_list_moderators(list_path)
+    try:
+        return ezmlm_list_moderators(list_path)
+    except Exception:
+        log.exception('Unable to provide list of mailing moderators of ' + mailing_list)
+        flask.abort(500)
 
 
 # noinspection PyUnusedLocal
@@ -151,7 +164,11 @@ def asf_add_subscriber(mailing_list, sub
     if not os.path.exists(list_path):
         flask.abort(500)
 
-    return ezmlm_add_subscriber(list_path, subscriber)
+    try:
+        return ezmlm_add_subscriber(list_path, subscriber)
+    except Exception:
+        log.exception('Unable to add subscriber %s to %s' % (subscriber, mailing_list))
+        flask.abort(500)
 
 
 @app.route('/v1/asf/lists/<mailing_list>/subscribers/<subscriber>', methods=['DELETE'])
@@ -162,7 +179,11 @@ def asf_remove_subscriber(mailing_list, 
     if not os.path.exists(list_path):
         flask.abort(500)
 
-    return ezmlm_remove_subscriber(list_path, subscriber)
+    try:
+        return ezmlm_remove_subscriber(list_path, subscriber)
+    except Exception:
+        log.exception('Unable to remove subscriber %s from %s' % (subscriber, mailing_list))
+        flask.abort(500)
 
 
 # noinspection PyUnusedLocal
@@ -185,7 +206,11 @@ def asf_add_moderator(mailing_list, mode
     if not os.path.exists(list_path):
         flask.abort(500)
 
-    return ezmlm_add_moderator(list_path, moderator)
+    try:
+        return ezmlm_add_moderator(list_path, moderator)
+    except Exception:
+        log.exception('Unable to add moderator %s to %s' % (moderator, mailing_list))
+        flask.abort(500)
 
 
 @app.route('/v1/asf/lists/<mailing_list>/moderators/<moderator>', methods=['DELETE'])
@@ -196,7 +221,11 @@ def asf_remove_moderator(mailing_list, m
     if not os.path.exists(list_path):
         flask.abort(500)
 
-    return ezmlm_remove_moderator(list_path, moderator)
+    try:
+        return ezmlm_remove_moderator(list_path, moderator)
+    except Exception:
+        log.exception('Unable to remove moderator %s from %s' % (moderator, mailing_list))
+        flask.abort(500)
 
 
 # noinspection PyUnusedLocal

Modified: labs/panopticon/pan-ezmlm/uwsgi.ini
URL: http://svn.apache.org/viewvc/labs/panopticon/pan-ezmlm/uwsgi.ini?rev=1606546&r1=1606545&r2=1606546&view=diff
==============================================================================
--- labs/panopticon/pan-ezmlm/uwsgi.ini (original)
+++ labs/panopticon/pan-ezmlm/uwsgi.ini Sun Jun 29 18:00:06 2014
@@ -1,7 +1,7 @@
 [uwsgi]
 http = 127.0.0.1:8081
 env = EZMLM_FLASK_CONFIG=../../../tests/data/ezmlm-flask.properties
-wsgi-file = ./bin/ezmlm.wsgi
+wsgi-file = ./bin/ezmlm.uwsgi.wsgi
 callable = app
 pythonpath = src
 processes = 4



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message