Skip to content

Commit 1a40064

Browse files
committed
Fixed django-compressor#25 - Catch IOErrors in the YUI and closure filter.
1 parent 38ac377 commit 1a40064

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

compressor/filters/closure.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ def output(self, **kwargs):
1414

1515
command = '%s %s' % (BINARY, arguments)
1616

17-
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
18-
p.stdin.write(self.content)
19-
p.stdin.close()
17+
try:
18+
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
19+
p.stdin.write(self.content)
20+
p.stdin.close()
2021

21-
filtered = p.stdout.read()
22-
p.stdout.close()
22+
filtered = p.stdout.read()
23+
p.stdout.close()
2324

24-
err = p.stderr.read()
25-
p.stderr.close()
25+
err = p.stderr.read()
26+
p.stderr.close()
27+
except IOError, e:
28+
raise FilterError(e)
2629

2730
if p.wait() != 0:
2831
if not err:
2932
err = 'Unable to apply Closure Compiler filter'
30-
3133
raise FilterError(err)
3234

3335
if self.verbose:

compressor/filters/yui.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,23 @@ def output(self, **kwargs):
2222
if self.verbose:
2323
command += ' --verbose'
2424

25-
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
26-
p.stdin.write(self.content)
27-
p.stdin.close()
25+
try:
26+
p = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
27+
p.stdin.write(self.content)
28+
p.stdin.close()
2829

29-
filtered = p.stdout.read()
30-
p.stdout.close()
30+
filtered = p.stdout.read()
31+
p.stdout.close()
3132

32-
err = p.stderr.read()
33-
p.stderr.close()
33+
err = p.stderr.read()
34+
p.stderr.close()
35+
36+
except IOError, e:
37+
raise FilterError(e)
3438

3539
if p.wait() != 0:
3640
if not err:
3741
err = 'Unable to apply YUI Compressor filter'
38-
3942
raise FilterError(err)
4043

4144
if self.verbose:

0 commit comments

Comments
 (0)