Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (1.1 kB)

1
#!/usr/bin/python
2
from os import environ
3
from os.path import basename
4
from sys import argv
5

    
6

    
7
if 'COMMISSIONING_APP_NAME' not in environ:
8
    progname = basename(argv[0])
9
    if progname.endswith('.py'):
10
        progname = progname[:-3]
11

    
12
    appname, sep, manage = progname.rpartition('-')
13
    if not appname:
14
        appname = manage
15

    
16
    if appname == 'manage':
17
        usage = """
18
COMMISSIONING_APP_NAME unconfigured.
19

20
either: ln -s ./manage.py appname-manage.py
21
    or: COMMISSIONING_APP_NAME=appname ./manage.py ...
22
"""
23
        print(usage)
24
        raise SystemExit
25

    
26
    environ['COMMISSIONING_APP_NAME'] = appname
27

    
28
from django.core.management import execute_manager
29
try:
30
    import settings # Assumed to be in the same directory.
31
except ImportError:
32
    import sys
33
    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
    sys.exit(1)
35

    
36
if __name__ == "__main__":
37
    execute_manager(settings)