new_contents: # "bokeh is imported and unused as a quick way to check for directory bokeh/bokeh/static/js
  # which is required for many (but not all) examples to run properly.
  import bokeh
  import glob
  import os
  import sys
  
  # TODO: --no-log option
  #       --test-all option (run through tests on every file in a given directory, rather than a small subset)
  #           - This is currently the default behavior
  #       --clean option (remove .html files created by running examples)
  
  
  def tester(TestingGround, HomeDir):
      """
      Collect and run all .py files in an examples directory, ignoring __init__.py
  
      User input is collected to determine a properly or improperly displayed page
      """
  
      os.chdir(TestingGround)
  
      if 'notebook' in TestingGround:
          command = "ipython notebook"
          suffix = ".ipynb"
      else:
          command = "python"
          suffix = ".py"
  
      TestFiles = [
          fileName for fileName in os.listdir('.') if fileName.endswith(suffix) and fileName != '__init__.py'
      ]
  
      Log = []
  
      get_input = check_py_ver()
  
      for fileName in TestFiles:
          try:
              print("\nOpening %s.\n" % fileName)
              os.system("%s %s" % (command, fileName))
  
              TestStatus = get_input("Did the plot(s) in %s display correctly? (y/n) " % fileName)
              while not TestStatus.startswith(('y', 'n')):
                  print()
                  TestStatus = get_input("Unexpected answer.  Please type y or n.  ")
              if TestStatus.startswith('n'):
                  ErrorReport = get_input("Please describe the problem: ")
                  Log.append("\n\n%s: \n %s" % (fileName, ErrorReport))
          except KeyboardInterrupt:
              break
  
      cleaner()
      os.chdir(HomeDir)
  
      if Log:
          logger(Log)
  
  
  def check_py_ver():
      """
      Check the version of Python to find the correct user input function.
      """
  
      if sys.version_info[0] >= 3:
          get_input = input
      else:
          get_input = raw_input
  
      return get_input
  
  
  def cleaner():
      """
      Remove all .html files created by running each of these python files.
      """
  
      dustbin = glob.glob('*.html')
      for dust in dustbin:
          os.remove(dust)
  
  
  def logger(ErrorArray):
      """
      Log errors by appending to a log.txt file.
      """
  
      with open(logfile, 'a') as f:
          print()
          print("\nWriting error log to %s" % logfile)
          f.write("%s\n" % base_dir)
          for error in ErrorArray:
              f.write("%s\n" % error)
  
  
  if __name__ == '__main__':
      if len(sys.argv) == 2 and sys.argv[1] in ['notebook', 'server', 'file']:
          target = sys.argv[1]
  
          logfile = "%sExamplesTestlog.txt" % target
          if os.path.exists(logfile):
              os.remove(logfile)
  
          base_dir = os.getcwd()
          test_dir = os.path.join(base_dir, 'plotting', target)
          tester(test_dir, base_dir)
      else:
          # # This is kept necessarily explicit so that you don't
          # accidentally provide a directory that has .html files
          # you don't want to have deleted.
          print("Please choose an examples directory to test in ('python bokehTest.py <plotting/server/file>)")
          sys.exit(1)
  
subject: Add script to help with testing interactive examples.