Commit 3a647662 by Ben Patterson

Update based on feedback.

parent 383de2e2
...@@ -641,22 +641,23 @@ def restart_django_servers(): ...@@ -641,22 +641,23 @@ def restart_django_servers():
)) ))
def collect_assets(systems, settings, debug_dict): def collect_assets(systems, settings, debug=None, collectstatic_log=None):
""" """
Collect static assets, including Django pipeline processing. Collect static assets, including Django pipeline processing.
`systems` is a list of systems (e.g. 'lms' or 'studio' or both) `systems` is a list of systems (e.g. 'lms' or 'studio' or both)
`settings` is the Django settings module to use. `settings` is the Django settings module to use.
`debug_dict` is describes where to pipe collectstatic output `debug` and `collectstatic_log` are used for determining where to
pipe collectstatic logging.
""" """
# unless specified, collectstatic (which can be very verbose) pipes to /dev/null # unless specified, collectstatic (which can be very verbose) pipes to /dev/null
collectstatic_stdout_str = "> /dev/null" collectstatic_stdout_str = "> /dev/null"
if debug_dict["debug"]: if debug:
# pipe to console # pipe to console
collectstatic_stdout_str = "" collectstatic_stdout_str = ""
if debug_dict["collect_log"]: if collectstatic_log:
# pipe to specified file # pipe to specified file
collectstatic_stdout_str = "> {output_file}".format(output_file=debug_dict["collect_log"]) collectstatic_stdout_str = "> {output_file}".format(output_file=collectstatic_log)
for sys in systems: for sys in systems:
sh(django_cmd(sys, settings, "collectstatic --noinput {logfile_str}".format( sh(django_cmd(sys, settings, "collectstatic --noinput {logfile_str}".format(
...@@ -790,9 +791,8 @@ def update_assets(args): ...@@ -790,9 +791,8 @@ def update_assets(args):
# Compile sass for themes and system # Compile sass for themes and system
execute_compile_sass(args) execute_compile_sass(args)
collectstatic_debug_dict = {"debug": args.debug, "collect_log": args.collect_log_file}
if args.collect: if args.collect:
collect_assets(args.system, args.settings, collectstatic_debug_dict) collect_assets(args.system, args.settings, debug=args.debug, collectstatic_log=args.collect_log_file)
if args.watch: if args.watch:
call_task( call_task(
......
...@@ -212,5 +212,5 @@ class test_collect_assets(PaverTestCase): ...@@ -212,5 +212,5 @@ class test_collect_assets(PaverTestCase):
pass pass
def test_collect_assets_debug(self): def test_collect_assets_debug(self):
debug_tuple = {"debug": False, "collect_log": None} collect_assets("foo", "bar", debug=True)
# TODO # TODO
...@@ -33,7 +33,7 @@ EXPECTED_PREPROCESS_ASSETS_COMMAND = ( ...@@ -33,7 +33,7 @@ EXPECTED_PREPROCESS_ASSETS_COMMAND = (
u" {system}/static/sass/*.scss {system}/static/themed_sass" u" {system}/static/sass/*.scss {system}/static/themed_sass"
) )
EXPECTED_COLLECT_STATIC_COMMAND = ( EXPECTED_COLLECT_STATIC_COMMAND = (
u"python manage.py {system} --settings={asset_settings} collectstatic --noinput > /dev/null" u"python manage.py {system} --settings={asset_settings} collectstatic --noinput {log_string}"
) )
EXPECTED_CELERY_COMMAND = ( EXPECTED_CELERY_COMMAND = (
u"python manage.py lms --settings={settings} celery worker --beat --loglevel=INFO --pythonpath=." u"python manage.py lms --settings={settings} celery worker --beat --loglevel=INFO --pythonpath=."
...@@ -197,6 +197,7 @@ class TestPaverServerTasks(PaverTestCase): ...@@ -197,6 +197,7 @@ class TestPaverServerTasks(PaverTestCase):
""" """
Verify the output of a server task. Verify the output of a server task.
""" """
log_string = options.get("log_string", "> /dev/null")
settings = options.get("settings", None) settings = options.get("settings", None)
asset_settings = options.get("asset-settings", None) asset_settings = options.get("asset-settings", None)
is_optimized = options.get("optimized", False) is_optimized = options.get("optimized", False)
...@@ -242,7 +243,7 @@ class TestPaverServerTasks(PaverTestCase): ...@@ -242,7 +243,7 @@ class TestPaverServerTasks(PaverTestCase):
expected_messages.extend(self.expected_sass_commands(system=system, asset_settings=expected_asset_settings)) expected_messages.extend(self.expected_sass_commands(system=system, asset_settings=expected_asset_settings))
if expected_collect_static: if expected_collect_static:
expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format( expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(
system=system, asset_settings=expected_asset_settings system=system, asset_settings=expected_asset_settings, log_string=log_string
)) ))
expected_run_server_command = EXPECTED_RUN_SERVER_COMMAND.format( expected_run_server_command = EXPECTED_RUN_SERVER_COMMAND.format(
system=system, system=system,
...@@ -258,6 +259,7 @@ class TestPaverServerTasks(PaverTestCase): ...@@ -258,6 +259,7 @@ class TestPaverServerTasks(PaverTestCase):
""" """
Verify the output of a server task. Verify the output of a server task.
""" """
log_string = options.get("log_string", "> /dev/null")
settings = options.get("settings", None) settings = options.get("settings", None)
asset_settings = options.get("asset_settings", None) asset_settings = options.get("asset_settings", None)
is_optimized = options.get("optimized", False) is_optimized = options.get("optimized", False)
...@@ -284,10 +286,10 @@ class TestPaverServerTasks(PaverTestCase): ...@@ -284,10 +286,10 @@ class TestPaverServerTasks(PaverTestCase):
expected_messages.extend(self.expected_sass_commands(asset_settings=expected_asset_settings)) expected_messages.extend(self.expected_sass_commands(asset_settings=expected_asset_settings))
if expected_collect_static: if expected_collect_static:
expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format( expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(
system="lms", asset_settings=expected_asset_settings system="lms", asset_settings=expected_asset_settings, log_string=log_string
)) ))
expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format( expected_messages.append(EXPECTED_COLLECT_STATIC_COMMAND.format(
system="cms", asset_settings=expected_asset_settings system="cms", asset_settings=expected_asset_settings, log_string=log_string
)) ))
expected_messages.append( expected_messages.append(
EXPECTED_RUN_SERVER_COMMAND.format( EXPECTED_RUN_SERVER_COMMAND.format(
......
...@@ -213,8 +213,8 @@ def run_all_servers(options): ...@@ -213,8 +213,8 @@ def run_all_servers(options):
# means that the optimized assets are ignored, so we skip collectstatic in that # means that the optimized assets are ignored, so we skip collectstatic in that
# case to save time. # case to save time.
if settings != DEFAULT_SETTINGS: if settings != DEFAULT_SETTINGS:
collect_assets(['lms'], asset_settings_lms, "/dev/null") collect_assets(['lms'], asset_settings_lms, collectstatic_log="/dev/null")
collect_assets(['studio'], asset_settings_cms, "/dev/null") collect_assets(['studio'], asset_settings_cms, collectstatic_log="/dev/null")
# Install an asset watcher to regenerate files that change # Install an asset watcher to regenerate files that change
call_task('pavelib.assets.watch_assets', options={'background': True}) call_task('pavelib.assets.watch_assets', options={'background': True})
......
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