def get_testcase_execution_files(testcase_filepath, tc_execution_dir, dirname):
    """Create directories for Results, Logs for testcase execution
    and get related files """
    extension = file_Utils.getExtension(dirname)
    dirpath = file_Utils.createDir_addtimestamp(tc_execution_dir, dirname)
    fullpath = get_execution_files(testcase_filepath, dirpath, extension)
    return fullpath
    def checkdir_create_file(self, inpdir, dirname, colocate=False):
        """Check if dir is present, if dir present create subdir nd files
        if dir not present try to create dir, subdir and files
        if not able to create dir use Warrior frameworks default dir structure."""

        dir_status = file_Utils.check_and_create_dir(
            inpdir)  # creates tc_results dir
        if dir_status:
            try:
                if colocate:
                    execdir = self.results_execdir
                else:
                    execdir = file_Utils.createDir_addtimestamp(
                        inpdir, self.nameonly)
                rfile = self.get_exec_file_by_type(dirname, execdir)
            except OSError:
                dir_status = False
            except Exception as exception:
                print_exception(exception)
                dir_status = False
        if dir_status is False:
            print_warning(
                "Creating directory/file(s) in provided path {0} failed. "
                "\n Hence Warrior Framework's default directory structure will be used "
                "for this execution.".format(inpdir))
            execdir = self.create_def_exec_dir()  # proj_exec_dir
            rfile = self.get_exec_file_by_type(dirname, execdir)
        return rfile, execdir
Esempio n. 3
0
    def get_result_files(self):
        """Get execution results dir and files """

        if self.res_startdir is not None:
            results_execdir = file_Utils.createDir_addtimestamp(self.res_startdir, self.nameonly)
            rfile = self.get_exec_file_by_type("Results", results_execdir)
        elif self.res_startdir is None:
            results_location = xml_Utils.getChildTextbyParentTag(self.filepath,
                                                                 'Details', 'Resultsdir')

            #get default results directory
            default_xml = Tools.__path__[0] + os.sep + 'w_settings.xml'
            default_resultsdir = get_credentials(default_xml, 'def_dir', ['Resultsdir'], 'Setting')
            #use the default directory if user didn't define it in test case/test suite/project
            if results_location is None or results_location is False:
                if default_resultsdir['Resultsdir'] is not None:
                    results_location = default_resultsdir['Resultsdir']

            if results_location is None or results_location is False\
            or str(results_location).strip() == "":
                results_execdir = self.create_def_exec_dir() #proj_exec_dir
                rfile = self.get_exec_file_by_type("Results", results_execdir)

            elif results_location is not None and results_location is not False:
                results_location_rel = str(results_location).strip()
                results_location = file_Utils.getAbsPath(results_location_rel,
                                                         os.path.dirname(self.filepath))
                rfile, results_execdir = self.checkdir_create_file(results_location, "Results")

        # print "printing results_execdir: ", results_execdir
        resultfile = file_Utils.getNewExtension(rfile, "xml")
        resultsdir = os.path.dirname(resultfile)
        return resultfile, resultsdir, results_execdir
    def get_log_files(self):
        """Get execution logs dir and results """

        if self.logs_startdir is not None:
            if self.logs_startdir == self.res_startdir:
                logs_execdir = self.results_execdir
            else:
                logs_execdir = file_Utils.createDir_addtimestamp(
                    self.logs_startdir, self.nameonly)
            logfile = self.get_exec_file_by_type("Logs", logs_execdir)

        elif self.logs_startdir is None:
            colocate = False
            logs_location = xml_Utils.getChildTextbyParentTag(
                self.filepath, 'Details', 'Logsdir')
            results_location = xml_Utils.getChildTextbyParentTag(
                self.filepath, 'Details', 'Resultsdir')

            #get default logs and results directory
            default_xml = Tools.__path__[0] + os.sep + 'w_settings.xml'
            default_logsdir = get_credentials(default_xml, 'def_dir',
                                              ['Logsdir'], 'Setting')
            default_resultsdir = get_credentials(default_xml, 'def_dir',
                                                 ['Resultsdir'], 'Setting')
            #use the default directory if user didn't define it in test case/test suite/project
            if results_location is None or results_location is False:
                if default_resultsdir['Resultsdir'] is not None:
                    results_location = default_resultsdir['Resultsdir']

            if logs_location is None or logs_location is False:
                if default_logsdir['Logsdir'] is not None:
                    logs_location = default_logsdir['Logsdir']

            if logs_location is None or logs_location is False\
            or str(logs_location).strip() == "":
                logs_execdir = self.create_def_exec_dir()
                logfile = self.get_exec_file_by_type('Logs', logs_execdir)

            elif logs_location is not None and logs_location is not False:
                logs_location_rel = str(logs_location).strip()
                logs_location = file_Utils.getAbsPath(
                    logs_location_rel, os.path.dirname(self.filepath))
                results_location_rel = str(results_location).strip()
                results_location = file_Utils.getAbsPath(
                    results_location_rel, os.path.dirname(self.filepath))
                if logs_location == results_location:
                    colocate = True

                logfile, logs_execdir = self.checkdir_create_file(
                    logs_location, 'Logs', colocate)

        # print "printing logs_execdir: ", logs_execdir
        logsdir = os.path.dirname(logfile)
        return logfile, logsdir, logs_execdir
Esempio n. 5
0
    def create_ws_execution(self):
        """Create execution dir in Warriorspace """
        curr_file_locn = os.path.realpath(__file__)
        war_locn = os.sep.join(curr_file_locn.split(os.sep)[:-3]) + os.sep + "Warrior"
        warriorspace = os.path.dirname(war_locn) + os.sep + "Warriorspace"
        #check_create_warriorspace(warriorspace)
        ws_execution = warriorspace + os.sep + "Execution"

        try:
            if not file_Utils.pathExists(ws_execution):
                os.makedirs(ws_execution)
            execution_dir = ws_execution
            self.ws_execution = file_Utils.createDir_addtimestamp(execution_dir, self.nameonly)
        except OSError as exception:
            print_error("Unable to create directory/file(s) under Warriorspace "\
                        "'{0}', hence aborting".format(ws_execution))
            print_exception(exception)
            exit(0)
        else:
            return self.ws_execution
 def get_defect_files(self):
     """get execution defects dir and results """
     defectsdir = file_Utils.createDir_addtimestamp(
         os.path.dirname(self.resultsdir), 'Defects')
     return defectsdir