def check_parent_dir(self, arg_fctrl_dir): Msg.dbg("Checking for control file in parent directory") Msg.user( "Test Root[%s], Work Dir[%s]" % (str(self.parent_data.test_root), str(self.parent_data.work_dir)), "CHECK-PARENT-DIR") if arg_fctrl_dir.startswith(".."): my_search_dir = arg_fctrl_dir my_work_dir = PathUtils.append_path(self.parent_data.test_root, self.parent_data.work_dir) my_test_root = self.parent_data.test_root Msg.user( "Updated Test Root[%s], Full Work Dir[%s], Search Dir[%s]" % (my_test_root, my_work_dir, my_search_dir), "CHECK-PARENT-DIR") while my_search_dir.startswith(".."): # First get the parent directory # The search [updated] directory started with [..] split path for both the work directory and the search directory # this fact that the [updated] search directory still begins with a [..], means that the work directory my_test_root, my_dumy = PathUtils.split_dir(my_test_root) my_work_dir, my_dumy = PathUtils.split_dir(my_work_dir) my_search_dir = my_search_dir[3:] Msg.user( "Updated Test Root[%s], Full Work Dir[%s], Search Dir[%s]" % (my_test_root, my_work_dir, my_search_dir), "CHECK-PARENT-DIR") my_filepath = str( PathUtils.append_path( my_work_dir, PathUtils.append_path(my_search_dir, self.fctrl_name))) Msg.user("File Path[%s] ... " % (my_filepath), "CHECK-PARENT-DIR") if PathUtils.check_found(my_filepath): self.fctrl_dir = PathUtils.append_path( my_work_dir, my_search_dir) return True my_filepath = str( PathUtils.append_path( my_test_root, PathUtils.append_path(my_search_dir, self.fctrl_name))) Msg.user("File Path[%s] ... " % (my_filepath), "CHECK-PARENT-DIR") if PathUtils.check_found(my_filepath): self.fctrl_dir = PathUtils.append_path( my_test_root, my_search_dir) return True raise Exception( "Control Item File[%s] Not Found in Parent Directory: [%s]" % (self.fctrl_name, arg_fctrl_dir)) return False
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 check_full_path(self, arg_fctrl_dir): # handle fully qualified path if found Msg.dbg("Checking for control file with real path[%s][%s]" % (str(arg_fctrl_dir), str(self.fctrl_name))) if arg_fctrl_dir.startswith("/"): # there is only one scenario where the control directory starts with the path delimiter and that is the path # is a real path from the root directory of the system, the control file must exist at that location if PathUtils.check_found( PathUtils.append_path(arg_fctrl_dir, self.fctrl_name)): self.fctrl_dir = arg_fctrl_dir return True raise Exception( "Control Item File: [%s] count not be located Not Found at [%s]" % (self.fctrl_name, arg_fctrl_dir)) return False