From a0b6a176f2b288b090595efde32fce58565dff9d Mon Sep 17 00:00:00 2001 From: Nate Hardison Date: Wed, 22 May 2013 14:49:22 -0700 Subject: [PATCH 1/3] Use .get instead of [] to access env hash If the `THEME_NAME` environment token isn't defined, then the application.scss.mako file will crash during preprocessing. Use .get to avoid a crash. --- lms/static/sass/application.scss.mako | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/static/sass/application.scss.mako b/lms/static/sass/application.scss.mako index 434475c6ac..4ec91dbf57 100644 --- a/lms/static/sass/application.scss.mako +++ b/lms/static/sass/application.scss.mako @@ -45,7 +45,7 @@ ## called themes//, with its base Sass file in ## themes//static/sass/_.scss. That one entry ## point can be used to @import in as many other things as needed. -% if not env['THEME_NAME'] is None: +% if not env.get('THEME_NAME') is None: // import theme's Sass overrides - @import '${env['THEME_NAME']}' + @import '${env.get('THEME_NAME')}' % endif From f826198214d569a0fe81aea15be96a1fb60e8373 Mon Sep 17 00:00:00 2001 From: Nate Hardison Date: Wed, 22 May 2013 19:34:14 -0700 Subject: [PATCH 2/3] Use "is not None" convention --- lms/static/sass/application.scss.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/static/sass/application.scss.mako b/lms/static/sass/application.scss.mako index 4ec91dbf57..c310347b6f 100644 --- a/lms/static/sass/application.scss.mako +++ b/lms/static/sass/application.scss.mako @@ -45,7 +45,7 @@ ## called themes//, with its base Sass file in ## themes//static/sass/_.scss. That one entry ## point can be used to @import in as many other things as needed. -% if not env.get('THEME_NAME') is None: +% if env.get('THEME_NAME') is not None: // import theme's Sass overrides @import '${env.get('THEME_NAME')}' % endif From daa0ac2f018cbbc0d747982b754ae889f0cf4878 Mon Sep 17 00:00:00 2001 From: Nate Hardison Date: Wed, 22 May 2013 19:42:22 -0700 Subject: [PATCH 3/3] Capture Mako exit code and fail fast if necessary Capture the exit code of the Mako template engine invocation on asset preprocessing and abort from the Rake task on failure. This will prevent the LMS from continuing its attempt to start up, preventing further configuration errors. --- rakefiles/assets.rake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rakefiles/assets.rake b/rakefiles/assets.rake index b7edaa1b02..c0757b712b 100644 --- a/rakefiles/assets.rake +++ b/rakefiles/assets.rake @@ -19,9 +19,11 @@ def preprocess_with_mako(filename) # strip off the .mako extension output_filename = filename.chomp(File.extname(filename)) - # just pipe from stdout into the new file + # just pipe from stdout into the new file, exiting on failure File.open(output_filename, 'w') do |file| file.write(`python -c '#{mako}'`) + exit_code = $?.to_i + abort "#{mako} failed with #{exit_code}" if exit_code.to_i != 0 end end