From 513382dd77cfce03c226ac7e3c99d23e9352c5e0 Mon Sep 17 00:00:00 2001 From: David Moreau Simard Date: Wed, 9 May 2018 12:24:43 -0400 Subject: [PATCH] Support specifying virtualenv path with or without activate_this.py The docs specified that the wsgi scripts expected an absolute path to a virtualenv yet what we really wanted was the activate_this.py path. Change this to support specifying the virtualenv path without activate_this.py which is more convenient. Change-Id: I110586dcc7b70a59c212695d1967169f7de0a232 --- ara/wsgi.py | 4 ++++ ara/wsgi_sqlite.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ara/wsgi.py b/ara/wsgi.py index 92e888f9..1c2188d6 100644 --- a/ara/wsgi.py +++ b/ara/wsgi.py @@ -36,7 +36,11 @@ import six if (int(os.getenv('ARA_WSGI_USE_VIRTUALENV', 0)) == 1 and os.getenv('ARA_WSGI_VIRTUALENV_PATH')): + # Backwards compatibility, we did not always suffix activate_this.py activate_this = os.getenv('ARA_WSGI_VIRTUALENV_PATH') + if 'activate_this.py' not in activate_this: + activate_this = os.path.join(activate_this, 'bin/activate_this.py') + if six.PY2: execfile(activate_this, dict(__file__=activate_this)) # nosec else: diff --git a/ara/wsgi_sqlite.py b/ara/wsgi_sqlite.py index 3c1389c2..a65d900a 100644 --- a/ara/wsgi_sqlite.py +++ b/ara/wsgi_sqlite.py @@ -53,7 +53,11 @@ import time if (int(os.getenv('ARA_WSGI_USE_VIRTUALENV', 0)) == 1 and os.getenv('ARA_WSGI_VIRTUALENV_PATH')): + # Backwards compatibility, we did not always suffix activate_this.py activate_this = os.getenv('ARA_WSGI_VIRTUALENV_PATH') + if 'activate_this.py' not in activate_this: + activate_this = os.path.join(activate_this, 'bin/activate_this.py') + if six.PY2: execfile(activate_this, dict(__file__=activate_this)) # nosec else: