def process(self): # Msg.dbg( "FileController::process()" ) # Msg.dbg( "FileController Contents: \n\"" + str( self.fcontrol ) + "\n" ) try: # Msg.lout( my_options["work-dir"], MsgLevel.dbg, "Work Director Stack" ) # a control file may iterate through to completion according to the amount set in num_runs for my_ndx in range(self.ctrl_item.iterations): # Msg.user( "Executing %d of %d Iterations, Control File: %s" % ( my_ndx + 1, self.ctrl_item.iterations, self.ctrl_item.file_path()) , "FILE-ITERATION") if self.is_terminated(): break try: my_item_ndx = 0 # each item in the control set exists as a dictionary for my_item_dict in self.fcontrol: try: if self.is_terminated(): break my_item_ndx += 1 # Msg.user( "Processing Line: %s" % (str( my_item_dict )), "CTRL-FILE" ) ) my_ctrl_item = ControlItem() my_ctrl_item.parent_fctrl = self.parent_fctrl my_ctrl_item.fctrl_item = str(my_item_dict) try: my_ctrl_item.load(self.mAppsInfo, my_item_dict, self.ctrl_item) except: raise my_item_type = my_ctrl_item.item_type() my_controller = None if my_item_type == ControlItemType.TaskItem: # Msg.dbg( "\nControl Item is a Control Task ..." ) my_controller = TaskController( self.mProcessQueue, self.mAppsInfo) elif my_item_type == ControlItemType.FileItem: # Msg.dbg( "\nControl Item is a Control File ..." ) my_controller = FileController( self.mProcessQueue, self.mAppsInfo, self.mControlFileLocals) else: raise Exception( "\"" + my_fctrl_name + "\": Unknown Item Type ...\nUnable to Process ... " ) if my_controller.load(my_ctrl_item): my_controller.set_on_fail_proc( self.on_fail_proc) my_controller.set_is_term_proc( self.is_term_proc) my_controller.process() # Msg.dbg( "%s: Controller Creation Complete" % ( my_ctrl_item.fctrl_name )) except TypeError as arg_ex: Msg.err(str(arg_ex)) my_err_queue_item = SummaryErrorQueueItem({ "error": "Item #%s Contains an Invalid Type" % (str(my_item_ndx)), "message": arg_ex, "path": self.ctrl_item.file_path(), "type": str(type(arg_ex)) }) if self.mProcessQueue.summary is not None: self.mProcessQueue.summary.queue.enqueue( my_err_queue_item) Msg.blank() except FileNotFoundError as arg_ex: Msg.err(str(arg_ex)) my_err_queue_item = SummaryErrorQueueItem({ "error": arg_ex, "message": "Control File Not Found ...", "path": self.ctrl_item.file_path(), "type": str(type(arg_ex)) }) if self.mProcessQueue.summary is not None: self.mProcessQueue.summary.queue.enqueue( my_err_queue_item) Msg.blank() except Exception as arg_ex: Msg.error_trace(str(arg_ex)) Msg.err(str(arg_ex)) Msg.blank() finally: my_controller = None my_item_dict = None except Exception as arg_ex: Msg.error_trace("[ERROR] - " + str(arg_ex)) Msg.err(str(arg_ex)) finally: pass finally: pass # Msg.dbg() return True
def process(self): for my_ndx in range(self.ctrl_item.iterations): if self.is_terminated(): break try: my_item_ndx = 0 for my_item_dict in self.fcontrol: try: if self.is_terminated(): break my_item_ndx += 1 my_ctrl_item = ControlItem() my_ctrl_item.parent_fctrl = self.parent_fctrl my_ctrl_item.fctrl_item = str(my_item_dict) try: my_ctrl_item.load( self.mAppsInfo, my_item_dict, self.ctrl_item, ) except BaseException: raise my_item_type = my_ctrl_item.item_type() my_controller = None if my_item_type == ControlItemType.TaskItem: my_controller = TaskController( self.mProcessQueue, self.mAppsInfo) elif my_item_type == ControlItemType.FileItem: my_controller = FileController( self.mProcessQueue, self.mAppsInfo, self.mControlFileLocals, ) else: raise Exception('"' + my_fctrl_name + '": Unknown Item Type ...\n' "Unable to Process ... ") if my_controller.load(my_ctrl_item): my_controller.set_on_fail_proc(self.on_fail_proc) my_controller.set_is_term_proc(self.is_term_proc) my_controller.process() except TypeError as arg_ex: Msg.err(str(arg_ex)) my_err_queue_item = SummaryErrorQueueItem({ "error": "Item #%s Contains an Invalid " "Type" % (str(my_item_ndx)), "message": arg_ex, "path": self.ctrl_item.file_path(), "type": str(type(arg_ex)), }) if self.mProcessQueue.summary is not None: self.mProcessQueue.summary.queue.enqueue( my_err_queue_item) Msg.blank() except FileNotFoundError as arg_ex: Msg.err(str(arg_ex)) my_err_queue_item = SummaryErrorQueueItem({ "error": arg_ex, "message": "Control File Not Found ...", "path": self.ctrl_item.file_path(), "type": str(type(arg_ex)), }) if self.mProcessQueue.summary is not None: self.mProcessQueue.summary.queue.enqueue( my_err_queue_item) Msg.blank() except Exception as arg_ex: Msg.error_trace(str(arg_ex)) Msg.err(str(arg_ex)) Msg.blank() finally: my_controller = None my_item_dict = None except Exception as arg_ex: Msg.error_trace("[ERROR] - " + str(arg_ex)) Msg.err(str(arg_ex)) return True