|
1 | 1 | # -*- coding: utf-8 -*-
|
2 |
| -from collections import OrderedDict |
3 |
| -from datetime import datetime |
4 |
| -from subprocess import Popen, PIPE |
5 | 2 | import base64
|
6 | 3 | import hashlib
|
7 | 4 | import itertools
|
8 | 5 | import json
|
9 | 6 | import logging
|
10 | 7 | import os
|
11 | 8 | import re
|
| 9 | +import tempfile |
12 | 10 | import textwrap
|
13 | 11 | import uuid
|
| 12 | +from collections import OrderedDict |
| 13 | +from datetime import datetime |
| 14 | +from subprocess import Popen, PIPE |
14 | 15 |
|
15 |
| -import psycopg2 |
16 | 16 | try:
|
17 | 17 | import sass as libsass
|
18 | 18 | except ImportError:
|
|
23 | 23 | from odoo import SUPERUSER_ID
|
24 | 24 | from odoo.http import request
|
25 | 25 | from odoo.modules.module import get_resource_path
|
26 |
| -from odoo.tools import func, misc, transpile_javascript, is_odoo_module, SourceMapGenerator |
| 26 | +from odoo.tools import func, misc, transpile_javascript, is_odoo_module, SourceMapGenerator, osutil |
27 | 27 | from odoo.tools.misc import html_escape as escape
|
28 | 28 | from odoo.tools.pycompat import to_text
|
29 | 29 |
|
@@ -1017,17 +1017,25 @@ def compile(self, source):
|
1017 | 1017 | if libsass is None:
|
1018 | 1018 | return super(ScssStylesheetAsset, self).compile(source)
|
1019 | 1019 |
|
1020 |
| - try: |
1021 |
| - return libsass.compile( |
1022 |
| - string=source, |
1023 |
| - include_paths=[ |
1024 |
| - self.bootstrap_path, |
1025 |
| - ], |
1026 |
| - output_style=self.output_style, |
1027 |
| - precision=self.precision, |
1028 |
| - ) |
1029 |
| - except libsass.CompileError as e: |
1030 |
| - raise CompileError(e.args[0]) |
| 1020 | + with tempfile.TemporaryFile() as newstderr: |
| 1021 | + try: |
| 1022 | + with osutil.redirect_fd(2, redirect_to=newstderr.fileno()): |
| 1023 | + return libsass.compile( |
| 1024 | + string=source, |
| 1025 | + include_paths=[ |
| 1026 | + self.bootstrap_path, |
| 1027 | + ], |
| 1028 | + output_style=self.output_style, |
| 1029 | + precision=self.precision, |
| 1030 | + ) |
| 1031 | + except libsass.CompileError as e: |
| 1032 | + raise CompileError(e.args[0]) |
| 1033 | + finally: |
| 1034 | + newstderr.seek(0) |
| 1035 | + warnings = newstderr.read().strip() |
| 1036 | + if warnings: |
| 1037 | + _logger.getChild('libsass').warning("%s", warnings.decode()) |
| 1038 | + |
1031 | 1039 |
|
1032 | 1040 | def get_command(self):
|
1033 | 1041 | try:
|
|
0 commit comments