Merge pull request #5532 from edx/adam/disable-pycontracts-on-startup
disable pycontracts except in development environments (PLAT-122)
This commit is contained in:
16
manage.py
16
manage.py
@@ -19,6 +19,7 @@ import os
|
||||
import sys
|
||||
import importlib
|
||||
from argparse import ArgumentParser
|
||||
import contracts
|
||||
|
||||
def parse_args():
|
||||
"""Parse edx specific arguments to manage.py"""
|
||||
@@ -41,6 +42,11 @@ def parse_args():
|
||||
choices=['lms', 'lms-xml', 'lms-preview'],
|
||||
default='lms',
|
||||
help='Which service variant to run, when using the aws environment')
|
||||
lms.add_argument(
|
||||
'--contracts',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Turn on pycontracts for local development')
|
||||
lms.set_defaults(
|
||||
help_string=lms.format_help(),
|
||||
settings_base='lms/envs',
|
||||
@@ -59,6 +65,11 @@ def parse_args():
|
||||
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.add_argument(
|
||||
'--contracts',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Turn on pycontracts for local development')
|
||||
cms.set_defaults(
|
||||
help_string=cms.format_help(),
|
||||
settings_base='cms/envs',
|
||||
@@ -86,6 +97,11 @@ if __name__ == "__main__":
|
||||
|
||||
os.environ.setdefault("SERVICE_VARIANT", edx_args.service_variant)
|
||||
|
||||
enable_contracts = os.environ.get('ENABLE_CONTRACTS', False)
|
||||
# can override with '--contracts' argument
|
||||
if not enable_contracts and not edx_args.contracts:
|
||||
contracts.disable_all()
|
||||
|
||||
if edx_args.help:
|
||||
print "Django:"
|
||||
# This will trigger django-admin.py to print out its help
|
||||
|
||||
Reference in New Issue
Block a user