code: def run_commands(command, number_to_run, temp_file):
      """
      This function will run the command for number_to_run number of times.  For each run,
      it store the screen print out into temp_file.  After finishing a run, it will go to
      temp_file and collect the run time information and store it in a list in result_dict
      which is a python dict structure.  The result_dict will be returned.
  
      :param command: string containing the command to be run
      :param number_to_run: integer denoting the number of times to run command
      :param temp_file: string containing file name to store run command output
  
      :return: result_dict: python dict containing run time in secs as a list
      """
      result_dict = dict()
  
      temp_string = command.split()
      testname = temp_string[-1]
      temp_string = testname.split("/")
      result_dict["test_name"] = temp_string[-1]
      result_dict["run_time_secs"] = []
  
      full_command = command + " > " + temp_file
  
      for run_index in range(0, number_to_run):
          child = subprocess.Popen(full_command, shell=True)
  
          while child.poll() is None:
              time.sleep(10)
          #        subprocess.call(full_command, shell=True)   # run the command,
  
          with open(
              temp_file, "r"
          ) as thefile:  # go into tempfile and grab test run info
              for each_line in thefile:
                  print(each_line)
  
                  temp_string = each_line.split()
                  if len(temp_string) > 0:
                      if temp_string[0] == "PASS":
                          test_time = temp_string[2]
                          try:
                              runtime = test_time[:-1]
                              result_dict["run_time_secs"].append(
                                  float(runtime)
                              )
                          except:
                              print(
                                  "Cannot convert run time.  It is {0}\n".format(
                                      runtime
                                  )
                              )
                          break
  
      return result_dict
  
file_path: h2o-3/scripts/collectUnitTestRunTime.py
imports: import sys
  import os
  import json
  import subprocess
  import time
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: run_commands(command, number_to_run, temp_file) and returns: result_dict