Commit e6288ad1 by Carlos Andrés Rocha

Fix manage.py to ouput the help of the django command if requested

Commands like the following were not working correctly:
```
$ python manage.py lms runserver --lms
```
parent edc62ff6
...@@ -20,7 +20,7 @@ from argparse import ArgumentParser ...@@ -20,7 +20,7 @@ from argparse import ArgumentParser
def parse_args(): def parse_args():
"""Parse edx specific arguments to manage.py""" """Parse edx specific arguments to manage.py"""
parser = ArgumentParser() parser = ArgumentParser()
subparsers = parser.add_subparsers(title='system', description='edx service to run') subparsers = parser.add_subparsers(title='system', description='edX service to run')
lms = subparsers.add_parser( lms = subparsers.add_parser(
'lms', 'lms',
...@@ -31,8 +31,8 @@ def parse_args(): ...@@ -31,8 +31,8 @@ def parse_args():
lms.add_argument('-h', '--help', action='store_true', help='show this help message and exit') lms.add_argument('-h', '--help', action='store_true', help='show this help message and exit')
lms.add_argument( lms.add_argument(
'--settings', '--settings',
help="Which django settings module to use from inside of lms.envs. If not provided, the DJANGO_SETTINGS_MODULE " help="Which django settings module to use under lms.envs. If not provided, the DJANGO_SETTINGS_MODULE "
"environment variable will be used if it is set, otherwise will default to lms.envs.dev") "environment variable will be used if it is set, otherwise it will default to lms.envs.dev")
lms.add_argument( lms.add_argument(
'--service-variant', '--service-variant',
choices=['lms', 'lms-xml', 'lms-preview'], choices=['lms', 'lms-xml', 'lms-preview'],
...@@ -52,8 +52,8 @@ def parse_args(): ...@@ -52,8 +52,8 @@ def parse_args():
) )
cms.add_argument( cms.add_argument(
'--settings', '--settings',
help="Which django settings module to use from inside cms.envs. If not provided, the DJANGO_SETTINGS_MODULE " help="Which django settings module to use under cms.envs. If not provided, the DJANGO_SETTINGS_MODULE "
"environment variable will be used if it is set, otherwise will default to cms.envs.dev") "environment variable will be used if it is set, otherwise it will default to cms.envs.dev")
cms.add_argument('-h', '--help', action='store_true', help='show this help message and exit') cms.add_argument('-h', '--help', action='store_true', help='show this help message and exit')
cms.set_defaults( cms.set_defaults(
help_string=cms.format_help(), help_string=cms.format_help(),
...@@ -62,7 +62,6 @@ def parse_args(): ...@@ -62,7 +62,6 @@ def parse_args():
service_variant='cms' service_variant='cms'
) )
edx_args, django_args = parser.parse_known_args() edx_args, django_args = parser.parse_known_args()
if edx_args.help: if edx_args.help:
...@@ -79,11 +78,13 @@ if __name__ == "__main__": ...@@ -79,11 +78,13 @@ if __name__ == "__main__":
os.environ["DJANGO_SETTINGS_MODULE"] = edx_args.settings_base.replace('/', '.') + "." + edx_args.settings os.environ["DJANGO_SETTINGS_MODULE"] = edx_args.settings_base.replace('/', '.') + "." + edx_args.settings
else: else:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", edx_args.default_settings) os.environ.setdefault("DJANGO_SETTINGS_MODULE", edx_args.default_settings)
os.environ.setdefault("SERVICE_VARIANT", edx_args.service_variant) os.environ.setdefault("SERVICE_VARIANT", edx_args.service_variant)
if edx_args.help: if edx_args.help:
print "Django:" print "Django:"
# This will trigger django-admin.py to print out its help # This will trigger django-admin.py to print out its help
django_args.insert(0, '--help') django_args.append('--help')
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment