From 9e148cdd90c61659c2f6e2d8b9172a4342fb63c0 Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Fri, 15 Jan 2010 11:00:38 -0500 Subject: [PATCH] Made the CSSTidyFilter function. Signed-off-by: Jannis Leidel --- AUTHORS | 1 + compressor/filters/csstidy.py | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6c78a04..82b2cf8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,6 +3,7 @@ Christian Metts Django Compressor's filters started life as the filters from Andreas Pelme's django-compress. +Aaron Godfrey Atamert Ölçgen Ben Spaulding Brad Whittington diff --git a/compressor/filters/csstidy.py b/compressor/filters/csstidy.py index acc1555..43f2017 100644 --- a/compressor/filters/csstidy.py +++ b/compressor/filters/csstidy.py @@ -1,6 +1,6 @@ -import os -import warnings +from subprocess import Popen, PIPE import tempfile +import warnings from django.conf import settings @@ -18,16 +18,17 @@ class CSSTidyFilter(FilterBase): tmp_file.flush() output_file = tempfile.NamedTemporaryFile(mode='w+b') - + command = '%s %s %s %s' % (BINARY, tmp_file.name, ARGUMENTS, output_file.name) - - command_output = os.popen(command).read() - + + command_output = Popen(command, shell=True, + stdout=PIPE, stdin=PIPE, stderr=PIPE).communicate() + filtered_css = output_file.read() output_file.close() tmp_file.close() - + if self.verbose: print command_output - + return filtered_css