Commit 3e9bbe25 by Calen Pennington

Make cms.dev environment work with manage.py

parent 8e125906
...@@ -31,8 +31,7 @@ def parse_args(): ...@@ -31,8 +31,7 @@ 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. Will search for a submodule of lms.envs first, and " help="Which django settings module to use from inside of lms.envs. If not provided, the DJANGO_SETTINGS_MODULE "
"if that module doesn't exist, will search in sys.path. 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 will default to lms.envs.dev")
lms.add_argument( lms.add_argument(
'-s', '--service-variant', '-s', '--service-variant',
...@@ -53,8 +52,7 @@ def parse_args(): ...@@ -53,8 +52,7 @@ def parse_args():
) )
cms.add_argument( cms.add_argument(
'--settings', '--settings',
help="Which django settings module to use. Will search for a submodule of cms.envs first, and " help="Which django settings module to use from inside cms.envs. If not provided, the DJANGO_SETTINGS_MODULE "
"if that module doesn't exist, will search in sys.path. 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 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(
...@@ -78,12 +76,7 @@ if __name__ == "__main__": ...@@ -78,12 +76,7 @@ if __name__ == "__main__":
edx_args, django_args = parse_args() edx_args, django_args = parse_args()
if edx_args.settings: if edx_args.settings:
try: os.environ["DJANGO_SETTINGS_MODULE"] = edx_args.settings_base.replace('/', '.') + "." + edx_args.settings
imp.find_module(edx_args.settings, [edx_args.settings_base])
os.environ["DJANGO_SETTINGS_MODULE"] = edx_args.settings_base.replace('/', '.') + "." + edx_args.settings
except ImportError:
imp.find_module(edx_args.settings)
os.environ["DJANGO_SETTINGS_MODULE"] = 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)
...@@ -94,4 +87,4 @@ if __name__ == "__main__": ...@@ -94,4 +87,4 @@ if __name__ == "__main__":
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
execute_from_command_line([sys.argv[0]] + django_args) execute_from_command_line([sys.argv[0]] + django_args)
\ No newline at end of file
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