Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1aba7f81
Commit
1aba7f81
authored
Oct 09, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable pycontracts except in development environments (PLAT-122)
parent
a3ac57bb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
5 deletions
+30
-5
manage.py
+16
-0
pavelib/servers.py
+14
-5
No files found.
manage.py
View file @
1aba7f81
...
@@ -15,6 +15,7 @@ import os
...
@@ -15,6 +15,7 @@ import os
import
sys
import
sys
import
importlib
import
importlib
from
argparse
import
ArgumentParser
from
argparse
import
ArgumentParser
import
contracts
def
parse_args
():
def
parse_args
():
"""Parse edx specific arguments to manage.py"""
"""Parse edx specific arguments to manage.py"""
...
@@ -37,6 +38,11 @@ def parse_args():
...
@@ -37,6 +38,11 @@ def parse_args():
choices
=
[
'lms'
,
'lms-xml'
,
'lms-preview'
],
choices
=
[
'lms'
,
'lms-xml'
,
'lms-preview'
],
default
=
'lms'
,
default
=
'lms'
,
help
=
'Which service variant to run, when using the aws environment'
)
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
(
lms
.
set_defaults
(
help_string
=
lms
.
format_help
(),
help_string
=
lms
.
format_help
(),
settings_base
=
'lms/envs'
,
settings_base
=
'lms/envs'
,
...
@@ -55,6 +61,11 @@ def parse_args():
...
@@ -55,6 +61,11 @@ def parse_args():
help
=
"Which django settings module to use under 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 it 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
.
add_argument
(
'--contracts'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Turn on pycontracts for local development'
)
cms
.
set_defaults
(
cms
.
set_defaults
(
help_string
=
cms
.
format_help
(),
help_string
=
cms
.
format_help
(),
settings_base
=
'cms/envs'
,
settings_base
=
'cms/envs'
,
...
@@ -82,6 +93,11 @@ if __name__ == "__main__":
...
@@ -82,6 +93,11 @@ if __name__ == "__main__":
os
.
environ
.
setdefault
(
"SERVICE_VARIANT"
,
edx_args
.
service_variant
)
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
:
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
...
...
pavelib/servers.py
View file @
1aba7f81
...
@@ -13,7 +13,7 @@ DEFAULT_PORT = {"lms": 8000, "studio": 8001}
...
@@ -13,7 +13,7 @@ DEFAULT_PORT = {"lms": 8000, "studio": 8001}
DEFAULT_SETTINGS
=
'devstack'
DEFAULT_SETTINGS
=
'devstack'
def
run_server
(
system
,
settings
=
None
,
port
=
None
,
skip_assets
=
False
):
def
run_server
(
system
,
settings
=
None
,
port
=
None
,
skip_assets
=
False
,
contracts
=
False
):
"""
"""
Start the server for the specified `system` (lms or studio).
Start the server for the specified `system` (lms or studio).
`settings` is the Django settings module to use; if not provided, use the default.
`settings` is the Django settings module to use; if not provided, use the default.
...
@@ -36,9 +36,12 @@ def run_server(system, settings=None, port=None, skip_assets=False):
...
@@ -36,9 +36,12 @@ def run_server(system, settings=None, port=None, skip_assets=False):
if
port
is
None
:
if
port
is
None
:
port
=
DEFAULT_PORT
[
system
]
port
=
DEFAULT_PORT
[
system
]
run_process
(
django_cmd
(
args
=
[
settings
,
'runserver'
,
'--traceback'
,
'--pythonpath=.'
,
'0.0.0.0:{}'
.
format
(
port
)]
system
,
settings
,
'runserver'
,
'--traceback'
,
'--pythonpath=.'
,
'0.0.0.0:{}'
.
format
(
port
)))
if
contracts
:
args
.
append
(
"--contracts"
)
run_process
(
django_cmd
(
system
,
*
args
))
@task
@task
...
@@ -86,8 +89,14 @@ def devstack(args):
...
@@ -86,8 +89,14 @@ def devstack(args):
parser
=
argparse
.
ArgumentParser
(
prog
=
'paver devstack'
)
parser
=
argparse
.
ArgumentParser
(
prog
=
'paver devstack'
)
parser
.
add_argument
(
'system'
,
type
=
str
,
nargs
=
1
,
help
=
"lms or studio"
)
parser
.
add_argument
(
'system'
,
type
=
str
,
nargs
=
1
,
help
=
"lms or studio"
)
parser
.
add_argument
(
'--fast'
,
action
=
'store_true'
,
default
=
False
,
help
=
"Skip updating assets"
)
parser
.
add_argument
(
'--fast'
,
action
=
'store_true'
,
default
=
False
,
help
=
"Skip updating assets"
)
parser
.
add_argument
(
'--no-contracts'
,
action
=
'store_true'
,
default
=
False
,
help
=
"Disable contracts. By default, they're enabled in devstack."
)
args
=
parser
.
parse_args
(
args
)
args
=
parser
.
parse_args
(
args
)
run_server
(
args
.
system
[
0
],
settings
=
'devstack'
,
skip_assets
=
args
.
fast
)
run_server
(
args
.
system
[
0
],
settings
=
'devstack'
,
skip_assets
=
args
.
fast
,
contracts
=
(
not
args
.
no_contracts
)
)
@task
@task
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment