diff options
| author | Soren Hansen <soren.hansen@rackspace.com> | 2010-09-08 17:18:35 +0000 |
|---|---|---|
| committer | Tarmac <> | 2010-09-08 17:18:35 +0000 |
| commit | 30cec546812799fba09a2bab2b3aa4aad712ae3c (patch) | |
| tree | 77603477c8b7b3f3241672fd1c466840cb6f32ed /bin/nova-api | |
| parent | f62e2a6aafc1a3895238adce003926cca4bd3cd8 (diff) | |
| parent | f2a3f9a622613ec1575e70ac9fe9655b485d9a6d (diff) | |
It's annoying and confusing to have to set PYTHONPATH to point to your
development tree before you run any of the scripts.
If you're lucky, it just fails (because you don't have nova in the default
search path (i.e. don't have them installed in /usr/lib/blah)) so that you can
fix it up.
If you're less lucky, you spend at least a couple of minutes wondering
why the cool changes you made to one of the nova modules don't take effect
until you realise it's because it's using the nova stuff in /usr/lib.
So, to save myself (and probably others) a bit of time, this patch adds
a snippet to each of the scripts in bin/ to detect this and set up the PYTHONPATH.
Diffstat (limited to 'bin/nova-api')
| -rwxr-xr-x | bin/nova-api | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/bin/nova-api b/bin/nova-api index a3ad5a0e1..ede09d38c 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -22,9 +22,19 @@ Tornado daemon for the main API endpoint. """ import logging +import os +import sys from tornado import httpserver from tornado import ioloop +# If ../nova/__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, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import server from nova import utils |
