[svgwg] Hopefully fix build script for windows

https://github.com/w3c/svgwg/commit/e8ce4c5199b41b276d76409197465f88439e988f
commit e8ce4c5199b41b276d76409197465f88439e988f
Author: Brian Birtles <birtles@gmail.com>
Date:   Fri Oct 10 10:46:57 2014 +0900

    Hopefully fix build script for windows

diff --git a/tools/build.py b/tools/build.py
index 352bbd1..ff0354a 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -45,6 +45,26 @@ def getstatus(cmd):
     status, output = getstatusoutput(cmd)
     return status
 
+def which(name, flags=os.X_OK):
+    """ which that works on Windows too.
+    
+    Based on http://twistedmatrix.com/trac/browser/tags/releases/twisted-8.2.0/twisted/python/procutils.py
+    """
+    result = []
+    exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
+    path = os.environ.get('PATH', None)
+    if path is None:
+        return []
+    for p in os.environ.get('PATH', '').split(os.pathsep):
+        p = os.path.join(p, name)
+        if os.access(p, flags):
+            result.append(p)
+        for e in exts:
+            pext = p + e
+            if os.access(pext, flags):
+                result.append(pext)
+    return result
+
 # could allow this to be passed in:
 repo_dir = os.getcwd()
 
@@ -114,10 +134,9 @@ if len(sys.argv) == 2 and sys.argv[1] == "-c":
 
 # See if we should call "node" or "nodejs":
 
-status, output = getstatusoutput("which nodejs")
-if getstatus("which nodejs") == 0:
+if which("nodejs") != []:
     node = "nodejs"
-elif getstatus("which node") == 0:
+elif which("node") != []:
     node = "node"
 elif getstatus("[ -e /home/svgwg/bin/node ]") == 0:
     node = "/home/svgwg/bin/node"


============================================================
/home/svgwg/bin/node "/home/svgwg/svgwg.org/git/svgwg/tools/publish/publish.js" --list-pages
Nothing to do.

Received on Friday, 10 October 2014 01:50:23 UTC