Add new --config flag to authentic2-ctl (fixes #5960)

--config expects the path to the config file, it --config is not used
the environment variable DJANGO_CONFIG_FILE is used instead.
This commit is contained in:
Benjamin Dauvergne 2014-09-26 19:11:23 +02:00
parent b47b15191b
commit 7ae6ffd6a7
1 changed files with 20 additions and 2 deletions

View File

@ -1,9 +1,27 @@
#!/usr/bin/env python
import os, sys
import os
import sys
if __name__ == "__main__":
config_file = False
argv = sys.argv[1:]
for arg in list(argv):
if arg.startswith('--'):
if arg.startswith('--config='):
config_file = arg.split('=')[1]
argv.pop(0)
else:
print >>sys.stderr, 'ERR: Unsupported flag', arg
sys.exit(1)
else:
break
if config_file:
os.environ['DJANGO_CONFIG_FILE'] = config_file
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "authentic2.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
execute_from_command_line(sys.argv[:1] + argv)