Commit 1d801441 by Timothée Peignier

use django tempfile implementation to provide windows support

parent 27216d38
import os from django.core.files import temp as tempfile
import tempfile
from pipeline.conf import settings from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor from pipeline.compressors import SubProcessCompressor
...@@ -7,18 +6,15 @@ from pipeline.compressors import SubProcessCompressor ...@@ -7,18 +6,15 @@ from pipeline.compressors import SubProcessCompressor
class CSSTidyCompressor(SubProcessCompressor): class CSSTidyCompressor(SubProcessCompressor):
def compress_css(self, css): def compress_css(self, css):
out_file, out_filename = tempfile.mkstemp() output_file = tempfile.NamedTemporaryFile(suffix='.pipeline')
out_file = os.fdopen(out_file, 'rb')
command = '%s - %s %s' % ( command = '%s - %s %s' % (
settings.PIPELINE_CSSTIDY_BINARY, settings.PIPELINE_CSSTIDY_BINARY,
settings.PIPELINE_CSSTIDY_ARGUMENTS, settings.PIPELINE_CSSTIDY_ARGUMENTS,
out_filename output_file.name
) )
self.execute_command(command, css) self.execute_command(command, css)
filtered_css = out_file.read() filtered_css = output_file.read()
out_file.close() output_file.close()
os.remove(out_filename)
return filtered_css return filtered_css
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