.build_web.py 872 B

1234567891011121314151617181920212223242526272829303132333435
  1. from shutil import copyfile
  2. from subprocess import check_output
  3. import sys
  4. import os
  5. import platform
  6. import subprocess
  7. Import("env")
  8. def is_tool(name):
  9. cmd = "where" if platform.system() == "Windows" else "which"
  10. try:
  11. check_output([cmd, name])
  12. return True
  13. except:
  14. return False;
  15. def build_web():
  16. if is_tool("npm"):
  17. os.chdir("web")
  18. print("Attempting to build webpage...")
  19. try:
  20. print check_output(["npm", "install"])
  21. print check_output(["node_modules/.bin/gulp"])
  22. copyfile("build/index.html.gz.h", "../dist/index.html.gz.h")
  23. except Exception as e:
  24. print "Encountered error building webpage: ", e
  25. print "WARNING: Failed to build web package. Using pre-built page."
  26. pass
  27. finally:
  28. os.chdir("..");
  29. build_web()