From d1a3964aa63c25f815d12633eaef2a4440321dad Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Wed, 5 Nov 2014 18:47:14 +0100 Subject: [PATCH] [FIX] ir_qweb: css asset: use which to find lessc and sass Also, use lessc.cmd instead of lessc on Windows. It allows to run lessc command with only nodejs and the less module (no cygwin). --- openerp/addons/base/ir/ir_qweb.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/ir/ir_qweb.py b/openerp/addons/base/ir/ir_qweb.py index 42adf45de52..ae1ddfadb4f 100644 --- a/openerp/addons/base/ir/ir_qweb.py +++ b/openerp/addons/base/ir/ir_qweb.py @@ -28,7 +28,7 @@ import openerp.tools.lru from openerp.http import request from openerp.tools.safe_eval import safe_eval as eval from openerp.osv import osv, orm, fields -from openerp.tools import html_escape as escape +from openerp.tools import html_escape as escape, which from openerp.tools.translate import _ _logger = logging.getLogger(__name__) @@ -1529,14 +1529,21 @@ class SassStylesheetAsset(PreprocessedCSS): return "/*! %s */\n%s" % (self.id, content) def get_command(self): - return ['sass', '--stdin', '-t', 'compressed', '--unix-newlines', '--compass', - '-r', 'bootstrap-sass'] + defpath = os.environ.get('PATH', os.defpath).split(os.pathsep) + sass = which('sass', path=os.pathsep.join(defpath)) + return [sass, '--stdin', '-t', 'compressed', '--unix-newlines', '--compass', + '-r', 'bootstrap-sass'] class LessStylesheetAsset(PreprocessedCSS): def get_command(self): + defpath = os.environ.get('PATH', os.defpath).split(os.pathsep) + if os.name == 'nt': + lessc = which('lessc.cmd', path=os.pathsep.join(defpath)) + else: + lessc = which('lessc', path=os.pathsep.join(defpath)) webpath = openerp.http.addons_manifest['web']['addons_path'] lesspath = os.path.join(webpath, 'web', 'static', 'lib', 'bootstrap', 'less') - return ['lessc', '-', '--clean-css', '--no-js', '--no-color', '--include-path=%s' % lesspath] + return [lessc, '-', '--clean-css', '--no-js', '--no-color', '--include-path=%s' % lesspath] def rjsmin(script): """ Minify js with a clever regex.