Commit 383de2e2 by Ben Patterson

Consider debug switch in how we decide what to do with logs

parent 9e49a7b3
...@@ -641,15 +641,26 @@ def restart_django_servers(): ...@@ -641,15 +641,26 @@ def restart_django_servers():
)) ))
def collect_assets(systems, settings, output_file): def collect_assets(systems, settings, debug_dict):
""" """
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
""" """
# unless specified, collectstatic (which can be very verbose) pipes to /dev/null
collectstatic_stdout_str = "> /dev/null"
if debug_dict["debug"]:
# pipe to console
collectstatic_stdout_str = ""
if debug_dict["collect_log"]:
# pipe to specified file
collectstatic_stdout_str = "> {output_file}".format(output_file=debug_dict["collect_log"])
for sys in systems: for sys in systems:
sh(django_cmd(sys, settings, "collectstatic --noinput > {logfile}".format( sh(django_cmd(sys, settings, "collectstatic --noinput {logfile_str}".format(
logfile=output_file logfile_str=collectstatic_stdout_str
))) )))
print("\t\tFinished collecting {} assets.".format(sys)) print("\t\tFinished collecting {} assets.".format(sys))
...@@ -766,8 +777,8 @@ def update_assets(args): ...@@ -766,8 +777,8 @@ def update_assets(args):
help="list of themes to compile sass for", help="list of themes to compile sass for",
) )
parser.add_argument( parser.add_argument(
'--collect-log', dest='collect_log_file', default="/dev/null", '--collect-log', dest='collect_log_file', default=None,
help="When running collectstatic, direct output to this log file", help="When running collectstatic, direct output to specified log file",
) )
args = parser.parse_args(args) args = parser.parse_args(args)
...@@ -779,8 +790,9 @@ def update_assets(args): ...@@ -779,8 +790,9 @@ 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, args.collect_log_file) collect_assets(args.system, args.settings, collectstatic_debug_dict)
if args.watch: if args.watch:
call_task( call_task(
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import ddt import ddt
import os import os
from unittest import TestCase from unittest import TestCase
from pavelib.assets import collect_assets
from paver.easy import call_task, path from paver.easy import call_task, path
from mock import patch from mock import patch
from watchdog.observers.polling import PollingObserver from watchdog.observers.polling import PollingObserver
...@@ -202,3 +203,14 @@ class TestPaverWatchAssetTasks(TestCase): ...@@ -202,3 +203,14 @@ class TestPaverWatchAssetTasks(TestCase):
self.assertIsInstance(sass_watcher_args[0], PollingObserver) self.assertIsInstance(sass_watcher_args[0], PollingObserver)
self.assertIsInstance(sass_watcher_args[1], list) self.assertIsInstance(sass_watcher_args[1], list)
self.assertItemsEqual(sass_watcher_args[1], self.expected_sass_directories) self.assertItemsEqual(sass_watcher_args[1], self.expected_sass_directories)
class test_collect_assets(PaverTestCase):
"""
Test the collectstatic process call
"""
def setUp(self):
pass
def test_collect_assets_debug(self):
debug_tuple = {"debug": False, "collect_log": None}
# TODO
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