Commit a3b28274 by Timothée Peignier

Ensure we flatten compressor command too

parent 012b1149
......@@ -4,15 +4,17 @@ import base64
import os
import posixpath
import re
import subprocess
from itertools import takewhile
from django.contrib.staticfiles.storage import staticfiles_storage
from django.utils.encoding import smart_bytes, force_text
from django.utils.six import string_types
from pipeline.conf import settings
from pipeline.utils import to_class, relpath
from pipeline.exceptions import CompressorError
from pipeline.utils import to_class, relpath
URL_DETECTOR = r"""url\((['"]){0,1}\s*(.*?)["']{0,1}\)"""
URL_REPLACER = r"""url\(__EMBED__(.+?)(\?\d+)?\)"""
......@@ -234,8 +236,14 @@ class CompressorBase(object):
class SubProcessCompressor(CompressorBase):
def execute_command(self, command, content):
import subprocess
pipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE,
argument_list = []
for flattening_arg in command:
if isinstance(flattening_arg, string_types):
argument_list.append(flattening_arg)
else:
argument_list.extend(flattening_arg)
pipe = subprocess.Popen(argument_list, shell=True, stdout=subprocess.PIPE,
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
if content:
content = smart_bytes(content)
......
......@@ -7,7 +7,6 @@ from django.test import TestCase
from pipeline.collector import default_collector
from pipeline.compilers import Compiler, CompilerBase, SubProcessCompiler
from pipeline.conf import settings
from pipeline.exceptions import CompilerError
from tests.utils import _, pipeline_settings
......
......@@ -171,10 +171,9 @@ class CompressorTest(TestCase):
""", output)
def test_compressor_subprocess_unicode(self):
tests_path = os.path.dirname(os.path.dirname(__file__))
output = SubProcessCompressor(False).execute_command(
'/usr/bin/env cat',
io.open(tests_path + '/assets/css/unicode.css', encoding="utf-8").read())
path = os.path.dirname(os.path.dirname(__file__))
content = io.open(path + '/assets/css/unicode.css', encoding="utf-8").read()
output = SubProcessCompressor(False).execute_command(('cat',), content)
self.assertEqual(""".some_class {
// Some unicode
content: "áéíóú";
......
from __future__ import unicode_literals
from django.conf import settings
from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.management import call_command
......
......@@ -7,7 +7,6 @@ from django.template import Template, Context
from django.test import TestCase
from pipeline.jinja2 import PipelineExtension
from pipeline.conf import settings
from tests.utils import pipeline_settings
......
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