Пример #1
0
    def get_plus_args(self):
        rtl_root = self.rtl.get("root")
        meta_args = self.rtl.get(
            "meta_args",
            "tc_mode=force railhouse=on rvbar=80000000 prefetch_drop_int=10 no_commit_cycles=6000"
        )  # by default set railhouse on

        # look for additional meta args if any
        add_meta_args = self.rtl.get("add_meta_args", "")
        if len(add_meta_args) > 0:
            meta_args = ' '.join([meta_args, add_meta_args])

        meta_converter = self.rtl.get("meta_converter")
        convert_cmd = meta_converter + " -r %s -m \"%s\"" % (rtl_root,
                                                             meta_args)
        plus_args, is_valid = SysUtils.get_command_output(convert_cmd)
        Msg.user("Meta args converting command: %s" % convert_cmd, "META-CONV")
        if not is_valid:
            Msg.user("Conversion failed.", "META-CONV")
            raise Exception("Meta conversion failed: %s" % meta_args)
        else:
            Msg.user("Converted to plus args: %s" % plus_args, "META-CONV")

        if self.rtl.get("filter"):
            plus_args = self.filterPlusArgs(plus_args)
            Msg.user("Filtered plus args: %s" % plus_args, "META-CONV")
        return plus_args
Пример #2
0
    def get_scm_data(cls, scm_type, a_path, a_cmd, a_cwd=None):
        """Returns an initialized data structure to hold SCM version data.

        :param str scm_type: 'svn' or 'git'
        :param str a_path: Project base folder
        :param str a_cmd: Command to return scm status detail
        :param str a_cwd:
        :return: dict containing SCM data
        :rtype: dict
        """
        version_info = {
            "scm_type": scm_type,
            "status": False,
            "error_msg": None,
            "folder": a_path,
            "url": "",
        }
        cmd_output, valid = SysUtils.get_command_output(a_cmd, arg_cwd=a_path)

        if not valid:
            version_info["error_msg"] = "Command error: %s" % cmd_output
        elif not cmd_output:
            version_info["error_msg"] = "Revision info not found"

        return version_info, cmd_output
Пример #3
0
    def convertRawResult(self, aMetaArgs, aFilter=False):
        current_dir = PathUtils.current_dir()
        PathUtils.chdir(self._mTopSimPath)
        result, is_valid = SysUtils.get_command_output(self._mMakeCommand + aMetaArgs)
        PathUtils.chdir(current_dir)

        if not is_valid:
            print("Converting meta args: %s to raw result failed." % aMetaArgs)
            sys.exit(1)

        if aFilter:
            args_list = result.split(" ")
            args_list = self.filterList(args_list)
            result = " ".join(args_list)

        return result
Пример #4
0
    def get_svn_revision(arg_class, arg_path):
        if not PathUtils.check_dir(arg_path):
            return 0, "Invalid path: %s" % arg_path

        cmd_output, valid = SysUtils.get_command_output("svn info %s" %
                                                        arg_path)
        if not valid:
            return 0, "Command error: %s" % cmd_output

        for line in cmd_output.split('\n'):
            if line.startswith("Revision: "):
                match_obj = re.match(VersionCtrlUtils.svn_revision_pattern,
                                     line)
                rev_value = int(match_obj.group(1))
                return rev_value, None

        return 0, "Revision info not found"
Пример #5
0
    def get_git_revision(cls, a_path):
        """Returns a populated data structure holding git version data.

        :param str a_path: Project base folder
        :return: Data structure holding git data
        :rtype: dict
        """
        status_cmd = "git log --oneline -n1 --decorate "
        version_info, cmd_output = cls.get_scm_data("git",
                                                    a_path,
                                                    status_cmd,
                                                    a_cwd=a_path)
        if version_info["error_msg"]:
            return version_info

        # Only process first line
        line = cmd_output.split("\n")[0]
        spaces = indices(line, " ")

        if not spaces:
            version_info["error_msg"] = "Command error: %s" % cmd_output

        version_info["version"] = line[:spaces[0]]
        parsed_data = cls.parse_git_log_line(line[spaces[0] + 1:])
        version_info.update(parsed_data)
        version_info["status"] = True

        # get origin URL
        cmd_output, valid = SysUtils.get_command_output(
            "git remote get-url origin", arg_cwd=a_path)

        if not valid:
            version_info["error_msg"] = "Command error: %s" % cmd_output
        elif not cmd_output:
            version_info["error_msg"] = "Revision origin URL not found"
        else:
            version_info["url"] = cmd_output

        return version_info
Пример #6
0
    def get_scm_data(cls, scm_type, a_path, a_cmd):
        """Returns an initialized data structure to hold SCM version data.

        :param str scm_type: 'svn' or 'git'
        :param str a_path: Project base folder
        :param str a_cmd: Command to return scm status detail
        :return: dict containing SCM data
        :rtype: dict
        """
        version_info = {
            'scm_type': scm_type,
            'status': False,
            'error_msg': None,
            'folder': a_path,
            'url': ''
        }
        cmd_output, valid = SysUtils.get_command_output(a_cmd)

        if not valid:
            version_info['error_msg'] = "Command error: %s" % cmd_output
        elif not cmd_output:
            version_info['error_msg'] = "Revision info not found"

        return version_info, cmd_output