forked from Polychart/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·48 lines (38 loc) · 1.08 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
"""
Convenient wrapper around django-admin.py.
Example usage: ./manage.py syncdb
"""
import errno
import os
import sys
from traceback import print_exc
def _mkdir(path):
try:
os.makedirs(path)
except OSError as err:
# If already exists as directory
if err.errno == errno.EEXIST and os.path.isdir(path):
return
raise
if __name__ == "__main__":
# Create directory required by logger
_mkdir('log/app')
# Set up environment properly
sys.path = ['server'] + sys.path
# Detect deployment vs local
if os.path.isfile('server/polychart/config/deployParams.py'):
os.environ["DJANGO_SETTINGS_MODULE"] = "polychart.config.deploy"
else:
os.environ["DJANGO_SETTINGS_MODULE"] = "polychart.config.local"
# Attempt to import Django
try:
from django.core.management import execute_from_command_line
except ImportError:
print_exc()
print
print 'Try rerunning this command like this:'
print ' virtualenv/bin/python2 manage.py'
sys.exit(1)
# Pass command-line args to Django
execute_from_command_line(sys.argv)