From: Zack Cerza Date: Fri, 22 May 2015 16:20:10 +0000 (-0600) Subject: Ensure our virtualenv's bin/ is in our PATH X-Git-Tag: 1.1.0~929^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f531f88315d1ca13c458c61345b07f604def362d;p=teuthology.git Ensure our virtualenv's bin/ is in our PATH So that we can run commands we install via pip from inside teuthology Signed-off-by: Zack Cerza --- diff --git a/teuthology/__init__.py b/teuthology/__init__.py index 6d19e6de9b..8144418c87 100644 --- a/teuthology/__init__.py +++ b/teuthology/__init__.py @@ -4,10 +4,20 @@ from .orchestra import monkey monkey.patch_all() import logging +import os +import sys __version__ = '0.1.0' + +# If we are running inside a virtualenv, ensure we have its 'bin' directory in +# our PATH. This doesn't happen automatically if scripts are called without +# first activating the virtualenv. +exec_dir = os.path.abspath(os.path.dirname(sys.argv[0])) +if os.path.split(exec_dir)[-1] == 'bin' and exec_dir not in os.environ['PATH']: + os.environ['PATH'] = ':'.join((exec_dir, os.environ['PATH'])) + # We don't need to see log entries for each connection opened logging.getLogger('requests.packages.urllib3.connectionpool').setLevel( logging.WARN)