def populate(self, arg_dict): self.work_dir = arg_dict[CtrlItmKeys.fdir] #Msg.trace() Msg.user("self.work_dir: %s" % (self.work_dir), "ParentData::populate()") self.test_root = arg_dict[CtrlItmKeys.test_root] self.mode = arg_dict[CtrlItmKeys.mode] self.force_path = arg_dict[CtrlItmKeys.force_path] self.action = arg_dict[CtrlItmKeys.action] self.process_queue = arg_dict[CtrlItmKeys.process_queue] self.force_cmd = arg_dict[CtrlItmKeys.force_cmd] self.process_max = arg_dict.get(CtrlItmKeys.process_max, CtrlItmDefs.process_max) self.iss_path = arg_dict.get(CtrlItmKeys.iss_path, CtrlItmDefs.iss_path) if not SysUtils.found(self.iss_path.find(self.test_root)): # Msg.user( "Test Root Not Found ..." ) # if not then prepend the test root self.iss_path = PathUtils.include_trailing_path_delimiter( self.test_root) + PathUtils.exclude_leading_path_delimiter( self.iss_path) Msg.user("Final Iss Path: %s" % (self.iss_path), "ISS_PATH") self.timeout = arg_dict.get(CtrlItmKeys.timeout, CtrlItmDefs.timeout) return self
def load_process_line(self, arg_line): if SysUtils.found(arg_line.find("ForceCommand")): my_glb, my_loc = SysUtils.exec_content(arg_line) self.load_gen_info(my_loc["ForceCommand"]) self.detail_flags |= SummaryDetail.ForceCmd elif SysUtils.found(arg_line.find("ForceResult")): my_glb, my_loc = SysUtils.exec_content(arg_line) self.load_gen_result(my_loc["ForceResult"]) self.detail_flags |= SummaryDetail.ForceResult elif SysUtils.found(arg_line.find("ISSCommand")): my_glb, my_loc = SysUtils.exec_content(arg_line) self.load_iss_info(my_loc["ISSCommand"]) self.detail_flags |= SummaryDetail.IssCmd elif SysUtils.found(arg_line.find("ISSResult")): my_glb, my_loc = SysUtils.exec_content(arg_line) self.load_iss_result(my_loc["ISSResult"]) self.detail_flags |= SummaryDetail.IssResult
def load_force_elog( self ): self.force_msg = None my_elog = "%s%s" % ( PathUtils.include_trailing_path_delimiter( self.work_dir ), self.force_elog ) # Msg.dbg( my_elog ) if SysUtils.failed( self.force_retcode ): Msg.fout( my_elog, "dbg" ) with open( my_elog , "r" ) as my_flog: try: for my_line in my_flog: if SysUtils.found( my_line.find( "[fail]" )): self.force_msg = my_line.replace( "[fail]", "" ).strip() # Msg.dbg( "Message: %s" % ( str( self.force_msg ))) break finally: my_flog.close()
def check_ctrl_dir(self, arg_fctrl_dir): Msg.user( "Checking for control file at relative path[%s] from test root" % (arg_fctrl_dir), "RELATIVE PATH") my_tmp_dir = arg_fctrl_dir if not SysUtils.found(my_tmp_dir.find(self.parent_data.test_root)): # Prepend the test_root on the work directory Msg.user("Building Control Directory ...", "RELATIVE PATH") my_tmp_dir = PathUtils.append_path(self.parent_data.test_root, my_tmp_dir) if PathUtils.check_found( PathUtils.append_path(my_tmp_dir, self.fctrl_name)): self.fctrl_dir = my_tmp_dir Msg.user("Setting Control Directory: %s ..." % (self.fctrl_dir), "RELATIVE PATH") return True return False
def check_work_dir(self, arg_fctrl_dir): # check the work directory Msg.dbg( "Checking for control file using implict path[%s] of current control file" % (str(arg_fctrl_dir))) if not self.parent_data.work_dir is None: my_tmp_dir = PathUtils.append_path(self.parent_data.work_dir, arg_fctrl_dir) if not SysUtils.found(my_tmp_dir.find(self.parent_data.test_root)): # Prepend the test_root on the work directory my_tmp_dir = PathUtils.append_path(self.parent_data.test_root, my_tmp_dir) if PathUtils.check_found( PathUtils.append_path(my_tmp_dir, self.fctrl_name)): self.fctrl_dir = my_tmp_dir # Msg.dbg( "Using Control File Directory: %s" % ( self.fctrl_dir )) return True return False
def extract_iss_data(self, arg_item_dict): # first get the iss dictionary # Msg.lout( arg_item_dict, "user", "RAW Item Dictionary ..." ) my_iss_data = arg_item_dict.get(CtrlItmKeys.iss, CtrlItmDefs.iss) my_iss_path = my_iss_data.get(CtrlItmKeys.iss_path, None) if my_iss_path is not None: # if the iss path was not specified then the iss path currently in the parent data instance is the correct one Msg.dbg("Iss Path: %s, Test Root: %s" % (my_iss_path, self.parent_data.test_root)) # check to see if path is absolute path if not SysUtils.found(my_iss_path.find( self.parent_data.test_root)): Msg.dbg("Test Root Not Found ...") # if not then prepend the test root my_iss_path = PathUtils.include_trailing_path_delimiter( self.parent_data.test_root ) + PathUtils.exclude_leading_path_delimiter(my_iss_path) self.parent_data.update_iss_path(my_iss_path) Msg.dbg("Final Iss Path: %s" % (self.parent_data.iss_path))
def resolve_file_location(self): my_fctrl_dir, self.fctrl_name = PathUtils.split_path( str(self.fctrl_name)) Msg.user( "Extracted File Path: %s, Control File Path: %s, Extracted File Name: %s" % (str(my_fctrl_dir), str(self.fctrl_dir), str(self.fctrl_name)), "FCTRL-DIR") Msg.user( "1 - Control Directory: %s, Force Directory: %s, Test Root: %s, Work Dir: %s, Control File: %s, self.fctrl_dir: %s" % (my_fctrl_dir, self.parent_data.force_path, self.parent_data.test_root, self.parent_data.work_dir, self.fctrl_name, self.fctrl_dir), "FCTRL-DIR") # if the name does not contain a path use the contol directory if my_fctrl_dir is None: my_fctrl_dir = self.fctrl_dir Msg.user( "Control Directory: %s, Force Directory: %s, Test Root: %s, Work Dir: %s, Control File: %s" % (my_fctrl_dir, self.parent_data.force_path, self.parent_data.test_root, self.parent_data.work_dir, self.fctrl_name), "FCTRL-DIR") # because of the requirement of not knowing and needing to discover the directory # situation it is necessary to search for the control file my_tmp = None my_tmp_dir = None # if the a directory was specified in the control name or a specifies as part of the control item it is # necessary to check for either a absolute path or relative parent path # Msg.dbg( "Checking: [%s] for [%s]" % ( my_fctrl_dir, self.fctrl_name )) if my_fctrl_dir is None: raise Exception( "Control File Location was not specified, File[%s]" % (self.fctrl_name)) if self.check_full_path(my_fctrl_dir): Msg.user("Using Real Path as Control Directory", "FILE_LOCATION") pass elif self.check_parent_dir(my_fctrl_dir): Msg.user("Using Parent Directory as Control Directory", "FILE_LOCATION") pass elif self.check_work_dir(my_fctrl_dir): Msg.user( "Using Current Control File Location as Control Directory", "FILE_LOCATION") pass elif self.check_ctrl_dir(my_fctrl_dir): Msg.user("Using Specified Control Directory as Control Directory", "FILE_LOCATION") pass else: if self.item_type() == ControlItemType.TaskItem: my_err_queue_item = SummaryErrorQueueItem({ "error": "Template Not Found at Specified Location", "message": "Template File Not Found ...", "path": self.file_path(), "type": str("FileNotFoundError") }) self.summary().queue.enqueue(my_err_queue_item) elif self.item_type() == ControlItemType.FileItem: my_err_queue_item = SummaryErrorQueueItem({ "error": "FileNotFoundError", "message": "Control File Not Found at Specified Location", "path": self.file_path(), "type": str("FileNotFoundError") }) self.summary().queue.enqueue(my_err_queue_item) raise Exception("File[%s] Not Found at Location Specified[%s]" % (self.fctrl_name, my_fctrl_dir)) # Msg.dbg( "Raw Control Directory: %s" % ( self.fctrl_dir )) # Msg.dbg( "Test Root: %s" % ( self.test_root )) # remove the test root if present if SysUtils.found(self.fctrl_dir.find(self.parent_data.test_root)): # Msg.dbg( "Test Root Found" ) self.fctrl_dir = self.fctrl_dir.replace(self.parent_data.test_root, "") # Msg.dbg( "Trimmed Control Directory: %s" % ( self.fctrl_dir )) # add the trailing path delimiter self.fctrl_dir = PathUtils.include_trailing_path_delimiter( self.fctrl_dir) Msg.user("Delimited Control Directory: %s" % (self.fctrl_dir), "FILE_LOCATION") return True
def load_force_log(self, arg_seed_only=False): self.default = None self.secondary = None self.total = None self.seed = None self.task_path = PathUtils.include_trailing_path_delimiter( self.work_dir) my_glog = "%s%s" % (self.task_path, self.force_log) Msg.dbg("Path: %s" % my_glog) # Msg.user( "Opening Generator Log File: %s" % ( my_glog )) with open(my_glog, "r") as my_flog: try: for my_line in my_flog: if SysUtils.found( my_line.find("Secondary Instructions Generated")): # my_secondary = my_line.replace( "[notice]Secondary Instructions Generated:", "" ).strip() # self.secondary = int( my_secondary ) my_lpos = my_line.find(':') my_count = int(my_line[my_lpos + 2:].strip()) # Msg.user( "Secondary Instructions: %d" % ( my_count )) self.secondary = my_count elif SysUtils.found( my_line.find("Default Instructions Generated")): # my_pos = my_line.find( ":" ) + 2 # my_default = my_line[ my_pos: ].strip() # get the count for this instruction type my_lpos = my_line.find(':') my_count = int(my_line[my_lpos + 2:].strip()) # Msg.user( "Default Instructions: %d" % ( my_count )) self.default = my_count # my_default = my_line.replace( "[notice]Default Instructions Generated:", "" ).strip() # self.default = int( my_default ) if SysUtils.found( my_line.find("Total Instructions Generated")): self.total = int( my_line.replace( "[notice]Total Instructions Generated: ", "").strip()) my_lpos = my_line.find(':') my_count = int(my_line[my_lpos + 2:].strip()) # Msg.user( "Total Instructions: %d" % ( my_count )) self.total = my_count if SysUtils.found(my_line.find("Initial seed")): self.seed = my_line.replace("[notice]", "").replace( "Initial seed = ", "").strip() # Msg.dbg( "Seed: %s" % ( self.seed )) # for simulation only the seed is needed if arg_seed_only: break if not (self.seed is None or self.total is None or self.secondary is None or self.default is None): break except Exception as arg_ex: # NOTE: Determine the possible errors and handle accordingly, for now just keep processing Msg.error_trace() Msg.err(str(arg_ex)) finally: my_flog.close()