From e6288ad19ce08ea82bf13c1ef467a06c67391db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s=20Rocha?= Date: Thu, 8 Aug 2013 19:06:41 -0400 Subject: [PATCH] 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 ``` --- manage.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/manage.py b/manage.py index d6b74025f5..ebaebe8b66 100755 --- a/manage.py +++ b/manage.py @@ -20,7 +20,7 @@ from argparse import ArgumentParser def parse_args(): """Parse edx specific arguments to manage.py""" 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', @@ -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( '--settings', - help="Which django settings module to use from inside of 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") + 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 it will default to lms.envs.dev") lms.add_argument( '--service-variant', choices=['lms', 'lms-xml', 'lms-preview'], @@ -52,8 +52,8 @@ def parse_args(): ) cms.add_argument( '--settings', - help="Which django settings module to use from inside 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") + 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 it will default to cms.envs.dev") cms.add_argument('-h', '--help', action='store_true', help='show this help message and exit') cms.set_defaults( help_string=cms.format_help(), @@ -62,7 +62,6 @@ def parse_args(): service_variant='cms' ) - edx_args, django_args = parser.parse_known_args() if edx_args.help: @@ -79,11 +78,13 @@ if __name__ == "__main__": os.environ["DJANGO_SETTINGS_MODULE"] = edx_args.settings_base.replace('/', '.') + "." + edx_args.settings else: os.environ.setdefault("DJANGO_SETTINGS_MODULE", edx_args.default_settings) + os.environ.setdefault("SERVICE_VARIANT", edx_args.service_variant) + if edx_args.help: print "Django:" # 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