From 725ce16c4c9324df3af41ffd8eadba0cccb52c72 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Thu, 22 Dec 2016 19:43:30 +0000 Subject: [PATCH] Added a variation on the manage.py script which will pick up our local python virtualenv under env/. This is for use when invoking django management commands externally, for instance in email pipelines from /etc/aliases. - Legacy-Id: 12625 --- ietf/virtualenv-manage.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ietf/virtualenv-manage.py diff --git a/ietf/virtualenv-manage.py b/ietf/virtualenv-manage.py new file mode 100644 index 000000000..c4128449e --- /dev/null +++ b/ietf/virtualenv-manage.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +import os +import sys + +path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +# Virtualenv support +virtualenv_activation = os.path.join(path, "env", "bin", "activate_this.py") +if os.path.exists(virtualenv_activation): + execfile(virtualenv_activation, dict(__file__=virtualenv_activation)) +else: + raise RuntimeError("Could not find the expected virtual python environment.") + +if not path in sys.path: + sys.path.insert(0, path) + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv)