# LIBTBX_SET_DISPATCHER_NAME dev.xia2.make_sphinx_html

from __future__ import division
import libtbx.load_env
from dials.util.procrunner import run_process
import shutil
import os

if (__name__ == "__main__") :
  xia2_dir = libtbx.env.find_in_repositories("xia2", optional=False)
  assert (xia2_dir is not None)
  dest_dir = os.path.join(xia2_dir, "html")
  if os.path.exists(dest_dir):
    shutil.rmtree(dest_dir)
  os.chdir(os.path.join(xia2_dir, "doc", "sphinx"))
  result = run_process(["make", "clean"])
  assert result['exitcode'] == 0, \
      'make clean failed with exit code %d' % result['exitcode']
  result = run_process(["make", "html"])
  assert result['exitcode'] == 0, \
      'make html failed with exit code %d' % result['exitcode']
  print "Moving HTML pages to", dest_dir
  shutil.move("build/html", dest_dir)

# LIBTBX_SET_DISPATCHER_NAME dev.xia2.make_sphinx_html

from __future__ import division
from libtbx import easy_run
import libtbx.load_env
import os.path as op
import shutil
import os
import sys

if (__name__ == "__main__") :
  xia2_dir = libtbx.env.find_in_repositories("xia2", optional=False)
  assert (xia2_dir is not None)
  dest_dir = op.join(xia2_dir, "html")
  if op.exists(dest_dir):
    shutil.rmtree(dest_dir)
  os.chdir(op.join(xia2_dir, "doc", "sphinx"))
  easy_run.call("make clean")
  easy_run.call("make html")
  print "Moving HTML pages to", dest_dir
  shutil.move("build/html", dest_dir)

--- 
+++ 
@@ -1,21 +1,23 @@
 # LIBTBX_SET_DISPATCHER_NAME dev.xia2.make_sphinx_html
 
 from __future__ import division
-from libtbx import easy_run
 import libtbx.load_env
-import os.path as op
+from dials.util.procrunner import run_process
 import shutil
 import os
-import sys
 
 if (__name__ == "__main__") :
   xia2_dir = libtbx.env.find_in_repositories("xia2", optional=False)
   assert (xia2_dir is not None)
-  dest_dir = op.join(xia2_dir, "html")
-  if op.exists(dest_dir):
+  dest_dir = os.path.join(xia2_dir, "html")
+  if os.path.exists(dest_dir):
     shutil.rmtree(dest_dir)
-  os.chdir(op.join(xia2_dir, "doc", "sphinx"))
-  easy_run.call("make clean")
-  easy_run.call("make html")
+  os.chdir(os.path.join(xia2_dir, "doc", "sphinx"))
+  result = run_process(["make", "clean"])
+  assert result['exitcode'] == 0, \
+      'make clean failed with exit code %d' % result['exitcode']
+  result = run_process(["make", "html"])
+  assert result['exitcode'] == 0, \
+      'make html failed with exit code %d' % result['exitcode']
   print "Moving HTML pages to", dest_dir
   shutil.move("build/html", dest_dir)
Check make exit codes and stop on error
