Make the scripts in bin/ detect if they're being run from a bzr checkout

or an extracted release tarball or whatever and adjust PYTHONPATH
accordingly.
This commit is contained in:
Soren Hansen 2010-09-08 10:45:39 +02:00
parent 937e8fae02
commit f2a3f9a622
10 changed files with 99 additions and 4 deletions

View File

@ -22,9 +22,19 @@ Tornado daemon for the main API endpoint.
""" """
import logging import logging
import os
import sys
from tornado import httpserver from tornado import httpserver
from tornado import ioloop 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 flags
from nova import server from nova import server
from nova import utils from nova import utils

View File

@ -21,6 +21,17 @@
Nova API daemon. Nova API daemon.
""" """
import os
import sys
# 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 api from nova import api
from nova import flags from nova import flags
from nova import utils from nova import utils

View File

@ -21,6 +21,17 @@
Twistd daemon for the nova compute nodes. Twistd daemon for the nova compute nodes.
""" """
import os
import sys
# 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 twistd from nova import twistd
from nova.compute import service from nova.compute import service

View File

@ -25,10 +25,13 @@ import logging
import os import os
import sys import sys
#TODO(joshua): there is concern that the user dnsmasq runs under will not # If ../nova/__init__.py exists, add ../ to Python search path, so that
# have nova in the path. This should be verified and if it is # it will override what happens to be installed in /usr/(local/)lib/python...
# not true the ugly line below can be removed possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) 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 flags
from nova import rpc from nova import rpc

View File

@ -29,6 +29,14 @@ import subprocess
import sys import sys
import urllib2 import urllib2
# 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 flags
from nova import utils from nova import utils
from nova.objectstore import image from nova.objectstore import image

View File

@ -21,9 +21,19 @@
Daemon for Nova RRD based instance resource monitoring. Daemon for Nova RRD based instance resource monitoring.
""" """
import os
import logging import logging
import sys
from twisted.application import service from twisted.application import service
# 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 twistd from nova import twistd
from nova.compute import monitor from nova.compute import monitor

View File

@ -22,9 +22,18 @@
Connects to the running ADMIN api in the api daemon. Connects to the running ADMIN api in the api daemon.
""" """
import os
import sys import sys
import time import time
# 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 flags
from nova import utils from nova import utils
from nova.auth import manager from nova.auth import manager

View File

@ -21,6 +21,17 @@
Twistd daemon for the nova network nodes. Twistd daemon for the nova network nodes.
""" """
import os
import sys
# 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 flags
from nova import twistd from nova import twistd

View File

@ -21,6 +21,17 @@
Twisted daemon for nova objectstore. Supports S3 API. Twisted daemon for nova objectstore. Supports S3 API.
""" """
import os
import sys
# 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 flags
from nova import utils from nova import utils
from nova import twistd from nova import twistd

View File

@ -21,6 +21,17 @@
Twistd daemon for the nova volume nodes. Twistd daemon for the nova volume nodes.
""" """
import os
import sys
# 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 twistd from nova import twistd
from nova.volume import service from nova.volume import service