Commits

Gael Pasgrimaud committed 30eaae2

pep8 + avoid bug with gp.recipe.node

  • Participants
  • Parent commits c20f79b

Comments (0)

Files changed (1)

js/lesscss/__init__.py

 from os.path import isfile
 from os.path import join
 import subprocess
-import logging
 import shutil
 import os
 
+
 def render_less(url):
     if url.endswith('.css'):
         return ('<link rel="stylesheet" type="text/css" href="%s" />' % url)
 lesscss_js = Resource(library, 'less.min.js', bottom=True)
 lesscss = lesscss_js
 
+
 class LessResource(Resource):
 
     def __init__(self, library, relpath, **kwargs):
-        fullpath = os.path.join(library.path, relpath)
+        fullpath = join(library.path, relpath)
         if 'LESSC' in os.environ:
             lessc(fullpath)
             depends = kwargs.get('depends', [])
                 fd = open(fullpath, 'w')
                 fd.write('// Not compiled yet\n')
                 fd.write('// set the LESSC environ variable ')
-                fd.write('to a valid lessc binary and relaunch your application\n')
+                fd.write(
+                    'to a valid lessc binary and relaunch your application\n')
                 fd.close()
         relpath += '.min.css'
         super(LessResource, self).__init__(library, relpath, **kwargs)
 
+
 def lessc(in_path, *args):
 
     lessc = None
     if 'LESSC' in os.environ:
-        lessc = os.environ['LESSC']
+        lessc = os.path.abspath(os.environ['LESSC'])
     if lessc is None or not isfile(lessc):
         for path in (('node_modules', os.path.expanduser('~/.node_modules'))):
             path = os.path.join(path, 'less', 'bin', 'lessc')
     if 'LESSC_ARGS' in os.environ:
         args = set(args.extend(os.environ['LESSC_ARGS'].split()))
 
-    cmd = [lessc]+list(args)+[in_path]
+    cmd = [lessc] + list(args) + [in_path]
+    print cmd
+    env = os.environ.copy()
+
+    # avoid a bug if you're using gp.recipe.node
+    del env['PYTHONPATH']
+
     p = subprocess.Popen(cmd,
                          stdout=subprocess.PIPE,
-                         stderr=subprocess.PIPE)
+                         stderr=subprocess.PIPE,
+                         env=env)
     p.wait()
 
     err = p.stderr.read()
     fd.close()
     return out_path
 
+
 def main():
     from optparse import OptionParser
     parser = OptionParser()
                     in_path = os.path.join(root, filename)
                     print in_path
                     out_path = lessc(in_path, '-x')
-                    print in_path, '->' , out_path
+                    print in_path, '->', out_path