def process_task_list(self): for my_task_file in self.task_list: # Msg.dbg( "Process Task File: %s" % ( my_task_file )) my_curdir = PathUtils.current_dir() try: # self.process_task_file( my_task_file ) self.process_task_file(my_task_file) except Exception as arg_ex: Msg.error_trace() Msg.err(str(arg_ex)) Msg.blank() finally: PathUtils.chdir(my_curdir)
def process_task(self, arg_task_file): try: # get the subdirectory index my_ndx = int(PathUtils.next_subdir()) # update the user label and send iteration message to the screen if user is active # my_usr_lbl = Msg.set_label( "user", "TEST-ITERATION" ) # Msg.user( "Executing Iteration #%d of Test File: %s" % ( my_ndx + 1, arg_task_file )) # Msg.set_label( "user", my_usr_lbl ) # create subdirectory and change into it PathUtils.chdir("%05d" % my_ndx, True) # save the task template file name with path to the control item self.ctrl_item.fname = arg_task_file # write out the control file # if the write was successful then enqueue the new control file name with real path my_ctrl_file = "%s_def_frun.py" % ( PathUtils.include_trailing_path_delimiter( PathUtils.current_dir())) PathUtils.touch("%sSTARTED" % PathUtils.include_trailing_path_delimiter( PathUtils.current_dir())) my_content = self.prepare(arg_task_file) if self.write_control_file(my_ctrl_file, my_content): # my_queue_item = ProcessQueueItem( my_ctrl_file, self.ctrl_item.parent_fctrl, self.ctrl_item.fctrl_item, self.ctrl_item.group, my_content ) my_queue_item = ProcessQueueItem( my_ctrl_file, self.ctrl_item, my_content ) # self.parent_fctrl, self.ctrl_item.fctrl_item, self.ctrl_item.group) self.ctrl_item.parent_data.process_queue.enqueue(my_queue_item) except Exception as arg_ex: Msg.error_trace() Msg.err(str(arg_ex)) # reraise to prevent adding to summary instance raise finally: PathUtils.chdir("..")
def process_task_file(self, arg_task_file): try: #my_usr_lbl = Msg.set_label( "user", "TASK" ) #Msg.user( "Old User Lbl: %s" % ( my_usr_lbl )) # NOTE: a task file can be but is not limited to being an test template file # set base task directory and extract the task id and update directory my_task_name = PathUtils.base_name(arg_task_file) my_task_dir = my_task_name.replace(".py", "") PathUtils.chdir(my_task_dir, True) # Msg.dbg( "Changed to Base Dir, my_task_name(%s), my_task_dir(%s)" % (my_task_name, my_task_dir)) # check for exiting sub-directories, and extract the task iteration count to prevent # unintended modifications to the original passed on the commafrom shared.path_utils import PathUtilsnd line for this task or # acquired from a control file item self.process_task(arg_task_file) finally: PathUtils.chdir("..")
if __name__ == "__main__": # save current working directory my_pwd = PathUtils.current_dir() try: my_module = UnitTestRun(the_force_root) Msg.info("\nForce Path: %s" % (str(the_force_root))) Msg.info("Original Directory: " + my_pwd) Msg.dbg("Processing Command Line and Loading Control File") my_module.load() Msg.dbg("Directory set to %s" % (PathUtils.current_dir())) if not PathUtils.chdir(the_force_root, False): Msg.dbg( "Directory Unchanged, using the current directory for output") my_module.run() Msg.dbg("Test Completed ....\n") Msg.blank() sys.exit(40) except getopt.GetoptError as arg_ex: from force_init import force_usage Msg.error_trace("[ERROR] - " + str(arg_ex)) force_usage(UsageStr) sys.exit(41)