From f531f88315d1ca13c458c61345b07f604def362d Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 22 May 2015 10:20:10 -0600 Subject: [PATCH] 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 --- teuthology/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) 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) -- 2.39.5