Skip to content

Commit

Permalink
"Merge pull request #454 from msabramo/more_helpful_error_if_sass_not…
Browse files Browse the repository at this point in the history
…_found\n\nMore helpful error if sass not found"
  • Loading branch information
miracle2k committed Mar 19, 2016
2 parents 3b47468 + fbe1b8b commit f710ac9
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/webassets/filter/sass.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from __future__ import print_function
import os, subprocess

from webassets.filter import Filter
from webassets.exceptions import FilterError, ImminentDeprecationWarning
from webassets.filter import ExternalTool
from webassets.cache import FilesystemCache


__all__ = ('Sass', 'SCSS')


class Sass(Filter):
class Sass(ExternalTool):
"""Converts `Sass <http://sass-lang.com/>`_ markup to real CSS.
Requires the Sass executable to be available externally. To install
Expand Down Expand Up @@ -188,24 +187,7 @@ def _apply_sass(self, _in, out, cd=None):
abs_path = self.resolve_path(lib)
args.extend(['-r', abs_path])

proc = subprocess.Popen(args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
# shell: necessary on windows to execute
# ruby files, but doesn't work on linux.
shell=(os.name == 'nt'),
cwd=child_cwd)
stdout, stderr = proc.communicate(_in.read().encode('utf-8'))

if proc.returncode != 0:
raise FilterError(('sass: subprocess had error: stderr=%s, '+
'stdout=%s, returncode=%s') % (
stderr, stdout, proc.returncode))
elif stderr:
print("sass filter has warnings:", stderr)

out.write(stdout.decode('utf-8'))
return self.subprocess(args, out, _in)

def input(self, _in, out, source_path, output_path, **kw):
if self.as_output:
Expand Down

0 comments on commit f710ac9

Please sign in to comment.