Statistics
| Branch: | Tag: | Revision:

root / commissioning / servers / django_server / manage.py @ 9c50a5ac

History | View | Annotate | Download (1.1 kB)

1 9f1a1bd0 Georgios D. Tsoukalas
#!/usr/bin/python
2 9f1a1bd0 Georgios D. Tsoukalas
from os import environ
3 9f1a1bd0 Georgios D. Tsoukalas
from os.path import basename
4 9f1a1bd0 Georgios D. Tsoukalas
from sys import argv
5 9f1a1bd0 Georgios D. Tsoukalas
6 9f1a1bd0 Georgios D. Tsoukalas
7 9f1a1bd0 Georgios D. Tsoukalas
if 'COMMISSIONING_APP_NAME' not in environ:
8 9f1a1bd0 Georgios D. Tsoukalas
    progname = basename(argv[0])
9 9f1a1bd0 Georgios D. Tsoukalas
    if progname.endswith('.py'):
10 9f1a1bd0 Georgios D. Tsoukalas
        progname = progname[:-3]
11 9f1a1bd0 Georgios D. Tsoukalas
12 9f1a1bd0 Georgios D. Tsoukalas
    appname, sep, manage = progname.rpartition('-')
13 9f1a1bd0 Georgios D. Tsoukalas
    if not appname:
14 9f1a1bd0 Georgios D. Tsoukalas
        appname = manage
15 9f1a1bd0 Georgios D. Tsoukalas
16 9f1a1bd0 Georgios D. Tsoukalas
    if appname == 'manage':
17 9f1a1bd0 Georgios D. Tsoukalas
        usage = """
18 9f1a1bd0 Georgios D. Tsoukalas
COMMISSIONING_APP_NAME unconfigured.
19 9f1a1bd0 Georgios D. Tsoukalas

20 9f1a1bd0 Georgios D. Tsoukalas
either: ln -s ./manage.py appname-manage.py
21 9f1a1bd0 Georgios D. Tsoukalas
    or: COMMISSIONING_APP_NAME=appname ./manage.py ...
22 9f1a1bd0 Georgios D. Tsoukalas
"""
23 9f1a1bd0 Georgios D. Tsoukalas
        print(usage)
24 9f1a1bd0 Georgios D. Tsoukalas
        raise SystemExit
25 9f1a1bd0 Georgios D. Tsoukalas
26 9f1a1bd0 Georgios D. Tsoukalas
    environ['COMMISSIONING_APP_NAME'] = appname
27 9f1a1bd0 Georgios D. Tsoukalas
28 9f1a1bd0 Georgios D. Tsoukalas
from django.core.management import execute_manager
29 9f1a1bd0 Georgios D. Tsoukalas
try:
30 9f1a1bd0 Georgios D. Tsoukalas
    import settings # Assumed to be in the same directory.
31 9f1a1bd0 Georgios D. Tsoukalas
except ImportError:
32 9f1a1bd0 Georgios D. Tsoukalas
    import sys
33 9f1a1bd0 Georgios D. Tsoukalas
    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
34 9f1a1bd0 Georgios D. Tsoukalas
    sys.exit(1)
35 9f1a1bd0 Georgios D. Tsoukalas
36 9f1a1bd0 Georgios D. Tsoukalas
if __name__ == "__main__":
37 9f1a1bd0 Georgios D. Tsoukalas
    execute_manager(settings)