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
This commit is contained in:
Henrik Levkowetz 2016-12-22 19:43:30 +00:00
parent c7a0d74481
commit 725ce16c4c

23
ietf/virtualenv-manage.py Normal file
View file

@ -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)