diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-04-24 14:03:27 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2011-04-24 14:03:27 -0700 |
| commit | 4c28ebbd1fc6e66309a59fe93a482fcc5ba48963 (patch) | |
| tree | 697f95eb514bb343a62a3c2f39bc2cf4c16aa48b /echo | |
| parent | b9ab84568e96b2686993dfb644c7eb174242b194 (diff) | |
allow apps to be run without setup.py
Diffstat (limited to 'echo')
| -rw-r--r-- | echo/echo/__init__.py | 1 | ||||
| -rw-r--r-- | echo/echo/echo.py | 24 |
2 files changed, 21 insertions, 4 deletions
diff --git a/echo/echo/__init__.py b/echo/echo/__init__.py index e69de29b..52bcde04 100644 --- a/echo/echo/__init__.py +++ b/echo/echo/__init__.py @@ -0,0 +1 @@ +from echo import app_factory diff --git a/echo/echo/echo.py b/echo/echo/echo.py index a600b0d0..21e16238 100644 --- a/echo/echo/echo.py +++ b/echo/echo/echo.py @@ -14,7 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from os import path +import os +import sys import eventlet from eventlet import wsgi @@ -27,6 +28,21 @@ except ImportError: import json import urllib +# If ../echo/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'echo', '__init__.py')): + # also use the local keystone + KEYSTONE_TOPDIR = os.path.normpath(os.path.join(POSSIBLE_TOPDIR, + os.pardir)) + if os.path.exists(os.path.join(KEYSTONE_TOPDIR, + 'keystone', + '__init__.py')): + sys.path.insert(0, KEYSTONE_TOPDIR) + sys.path.insert(0, POSSIBLE_TOPDIR) + """ Echo: a dummy service for OpenStack auth testing. It returns request info. @@ -38,8 +54,8 @@ class EchoApp(object): self.envr = environ self.start = start_response self.dom = self.toDOM(environ) - echo_xsl = path.join(path.abspath(\ - path.dirname(__file__)), "xsl/echo.xsl") + echo_xsl = os.path.join(os.path.abspath(\ + os.path.dirname(__file__)), "xsl/echo.xsl") self.transform = etree.XSLT(etree.parse(echo_xsl)) def __iter__(self): @@ -107,6 +123,6 @@ def app_factory(global_conf, **local_conf): if __name__ == "__main__": app = loadapp("config:" + \ - path.join(path.abspath(path.dirname(__file__)), "echo.ini"), \ + os.path.join(os.path.abspath(os.path.dirname(__file__)), "echo.ini"), \ global_conf={"log_name": "echo.log"}) wsgi.server(eventlet.listen(('', 8090)), app) |
