Merge branch 'pr/101'

This commit is contained in:
Martin Zimmermann 2014-06-15 16:56:03 +02:00
commit 33ce5959e9

View File

@ -1,8 +1,12 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
import sys
import os import os
import os.path
import logging import logging
from glob import glob
from werkzeug.wsgi import DispatcherMiddleware from werkzeug.wsgi import DispatcherMiddleware
from werkzeug.wrappers import Response from werkzeug.wrappers import Response
@ -43,14 +47,19 @@ class Dispatcher(DispatcherMiddleware):
resp = Response("\n".join(self.isso.keys()), 404, content_type="text/plain") resp = Response("\n".join(self.isso.keys()), 404, content_type="text/plain")
return resp(environ, start_response) return resp(environ, start_response)
settings = os.environ.get("ISSO_SETTINGS")
if "ISSO_SETTINGS" not in os.environ: if settings:
logger.fatal('no such environment variable: ISSO_SETTINGS') if os.path.isdir(settings):
else: conf_glob = os.path.join(os.environ["ISSO_SETTINGS"], '*.cfg')
confs = os.environ["ISSO_SETTINGS"].split(";") confs = glob(conf_glob)
for path in confs:
if not os.path.isfile(path):
logger.fatal("%s: no such file", path)
break
else:
application = wsgi.SubURI(Dispatcher(*confs)) application = wsgi.SubURI(Dispatcher(*confs))
else:
confs = os.environ["ISSO_SETTINGS"].split(";")
for path in confs:
if not os.path.isfile(path):
logger.fatal("%s: no such file", path)
sys.exit(1)
application = wsgi.SubURI(Dispatcher(*confs))
else:
logger.fatal('environment variable ISSO_SETTINGS or ISSO_SETTINGS_DIR must be set')