Skip to content

Commit 725ce16

Browse files
committed
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
1 parent c7a0d74 commit 725ce16

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

ietf/virtualenv-manage.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import sys
5+
6+
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
7+
8+
# Virtualenv support
9+
virtualenv_activation = os.path.join(path, "env", "bin", "activate_this.py")
10+
if os.path.exists(virtualenv_activation):
11+
execfile(virtualenv_activation, dict(__file__=virtualenv_activation))
12+
else:
13+
raise RuntimeError("Could not find the expected virtual python environment.")
14+
15+
if not path in sys.path:
16+
sys.path.insert(0, path)
17+
18+
if __name__ == "__main__":
19+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
20+
21+
from django.core.management import execute_from_command_line
22+
23+
execute_from_command_line(sys.argv)

0 commit comments

Comments
 (0)