当前位置: 首页>>代码示例>>Python>>正文


Python checks.check_install函数代码示例

本文整理汇总了Python中rbtools.utils.checks.check_install函数的典型用法代码示例。如果您正苦于以下问题:Python check_install函数的具体用法?Python check_install怎么用?Python check_install使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了check_install函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_repository_info

    def get_repository_info(self):
        if not check_install('svn help'):
            return None

        # Get the SVN repository path (either via a working copy or
        # a supplied URI)
        svn_info_params = ["svn", "info"]

        if self.options.repository_url:
            svn_info_params.append(self.options.repository_url)

        data = execute(svn_info_params,
                       ignore_errors=True)

        m = re.search(r'^Repository Root: (.+)$', data, re.M)
        if not m:
            return None

        path = m.group(1)

        m = re.search(r'^URL: (.+)$', data, re.M)
        if not m:
            return None

        base_path = m.group(1)[len(path):] or "/"

        m = re.search(r'^Repository UUID: (.+)$', data, re.M)
        if not m:
            return None

        # Now that we know it's SVN, make sure we have GNU diff installed,
        # and error out if we don't.
        check_gnu_diff()

        return SVNRepositoryInfo(path, base_path, m.group(1))
开发者ID:CheshireBat,项目名称:rbtools,代码行数:35,代码来源:svn.py

示例2: get_repository_info

    def get_repository_info(self):
        """
        Find out information about the current Bazaar branch (if any) and return
        it.

        """
        if not check_install("bzr help"):
            return None

        if self.options.repository_url:
            return RepositoryInfo(
                path=self.options.repository_url,
                base_path="/",  # Diffs are always relative to the root.
                supports_parent_diffs=True,
            )

        branch = None

        for location in ["submit_branch", "parent_location"]:
            branch = self._get_config(location)
            if branch is not None:
                break

        if branch is None:
            return None

        return RepositoryInfo(
            path=branch, base_path="/", supports_parent_diffs=True  # Diffs are always relative to the root.
        )
开发者ID:dchichkov,项目名称:rbtools,代码行数:29,代码来源:bazaar.py

示例3: get_repository_info

    def get_repository_info(self):
        if not check_install(['cvs']):
            logging.debug('Unable to execute "cvs": skipping CVS')
            return None

        cvsroot_path = os.path.join('CVS', 'Root')

        if not os.path.exists(cvsroot_path):
            return None

        with open(cvsroot_path, 'r') as fp:
            repository_path = fp.read().strip()

        i = repository_path.find('@')
        if i != -1:
            repository_path = repository_path[i + 1:]

        i = repository_path.rfind(':')
        if i != -1:
            host = repository_path[:i]
            try:
                canon = socket.getfqdn(host)
                repository_path = repository_path.replace('%s:' % host,
                                                          '%s:' % canon)
            except socket.error as msg:
                logging.error('failed to get fqdn for %s, msg=%s',
                              host, msg)

        return RepositoryInfo(path=repository_path)
开发者ID:clach04,项目名称:rbtools,代码行数:29,代码来源:cvs.py

示例4: get_repository_info

    def get_repository_info(self):
        if not check_install('cm version'):
            return None

        # Get the repository that the current directory is from.  If there
        # is more than one repository mounted in the current directory,
        # bail out for now (in future, should probably enter a review
        # request per each repository.)
        split = execute(["cm", "ls", "--format={8}"], split_lines=True,
                        ignore_errors=True)
        m = re.search(r'^rep:(.+)$', split[0], re.M)

        if not m:
            return None

        # Make sure the repository list contains only one unique entry
        if len(split) != split.count(split[0]):
            # Not unique!
            die('Directory contains more than one mounted repository')

        path = m.group(1)

        # Get the workspace directory, so we can strip it from the diff output
        self.workspacedir = execute(["cm", "gwp", ".", "--format={1}"],
                                    split_lines=False,
                                    ignore_errors=True).strip()

        logging.debug("Workspace is %s" % self.workspacedir)

        return RepositoryInfo(path,
                              supports_changesets=True,
                              supports_parent_diffs=False)
开发者ID:NurKaynar,项目名称:hacklab,代码行数:32,代码来源:plastic.py

示例5: __init__

    def __init__(self, config=None, options=None):
        super(TFSClient, self).__init__(config, options)

        self.tf = None
        tf_locations = []

        if getattr(self.options, 'tf_cmd', None):
            tf_locations.append(self.options.tf_cmd)

        if sys.platform.startswith('win'):
            # First check in the system path. If that doesn't work, look in the
            # two standard install locations.
            tf_locations.extend([
                'tf.cmd',
                r'%programfiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\tf.cmd',
                r'%programfiles%\Microsoft Team Foundation Server 12.0\Tools\tf.cmd',
            ])
        else:
            tf_locations.append('tf')

        for location in tf_locations:
            location = os.path.expandvars(location)

            if check_install([location, 'help']):
                self.tf = location
                break
开发者ID:dacaiguoguo,项目名称:rbtools,代码行数:26,代码来源:tfs.py

示例6: get_repository_info

    def get_repository_info(self):
        if not check_install(['cvs']):
            return None

        cvsroot_path = os.path.join("CVS", "Root")

        if not os.path.exists(cvsroot_path):
            return None

        fp = open(cvsroot_path, "r")
        repository_path = fp.read().strip()
        fp.close()

        i = repository_path.find("@")
        if i != -1:
            repository_path = repository_path[i + 1:]

        i = repository_path.rfind(":")
        if i != -1:
            host = repository_path[:i]
            try:
                canon = socket.getfqdn(host)
                repository_path = repository_path.replace('%s:' % host,
                                                          '%s:' % canon)
            except socket.error, msg:
                logging.error("failed to get fqdn for %s, msg=%s"
                              % (host, msg))
开发者ID:ceagan,项目名称:rbtools,代码行数:27,代码来源:cvs.py

示例7: get_repository_info

    def get_repository_info(self):
        """
        Find out information about the current Bazaar branch (if any) and
        return it.
        """
        if not check_install("bzr help"):
            return None

        bzr_info = execute(["bzr", "info"], ignore_errors=True)

        if "ERROR: Not a branch:" in bzr_info:
            # This is not a branch:
            repository_info = None
        else:
            # This is a branch, let's get its attributes:
            branch_match = re.search(self.BRANCH_REGEX, bzr_info, re.MULTILINE)

            path = branch_match.group("branch_path")
            if path == ".":
                path = os.getcwd()

            repository_info = RepositoryInfo(
                path=path,
                base_path="/",    # Diffs are always relative to the root.
                supports_parent_diffs=True)

        return repository_info
开发者ID:adembo,项目名称:rbtools,代码行数:27,代码来源:bazaar.py

示例8: get_repository_info

    def get_repository_info(self):
        if not check_install('cm version'):
            return None

        # Get the workspace directory, so we can strip it from the diff output
        self.workspacedir = execute(["cm", "gwp", ".", "--format={1}"],
                                    split_lines=False,
                                    ignore_errors=True).strip()

        logging.debug("Workspace is %s" % self.workspacedir)

        # Get the repository that the current directory is from
        split = execute(["cm", "ls", self.workspacedir, "--format={8}"], split_lines=True,
                        ignore_errors=True)

        # remove blank lines
        split = filter(None, split)

        m = re.search(r'^rep:(.+)$', split[0], re.M)

        if not m:
            return None

        path = m.group(1)

        return RepositoryInfo(path,
                              supports_changesets=True,
                              supports_parent_diffs=False)
开发者ID:PlasticSCM,项目名称:rbtools,代码行数:28,代码来源:plastic.py

示例9: get_repository_info

    def get_repository_info(self):
        """
        Find out information about the current Bazaar branch (if any) and
        return it.
        """
        if not check_install(['bzr', 'help']):
            logging.debug('Unable to execute "bzr help": skipping Bazaar')
            return None

        bzr_info = execute(['bzr', 'info'], ignore_errors=True)

        if 'ERROR: Not a branch:' in bzr_info:
            # This is not a branch:
            repository_info = None
        else:
            # This is a branch, let's get its attributes:
            branch_match = re.search(self.BRANCH_REGEX, bzr_info, re.MULTILINE)

            path = branch_match.group('branch_path')
            if path == '.':
                path = os.getcwd()

            repository_info = RepositoryInfo(
                path=path,
                base_path='/',    # Diffs are always relative to the root.
                supports_parent_diffs=True)

        return repository_info
开发者ID:acres-com-au,项目名称:rbtools,代码行数:28,代码来源:bazaar.py

示例10: get_repository_info

    def get_repository_info(self):
        """Return the repository info object.

        Returns:
            rbtools.clients.RepositoryInfo:
            The repository info structure.
        """
        if not check_install(['hg', '--help']):
            logging.debug('Unable to execute "hg --help": skipping Mercurial')
            return None

        self._init()

        if not self.hg_root:
            # hg aborted => no mercurial repository here.
            return None

        if self._type == 'svn':
            return self._calculate_hgsubversion_repository_info(self._svn_info)
        else:
            path = self.hg_root
            base_path = '/'

            if self._remote_path:
                path = self._remote_path[1]
                base_path = ''

            return RepositoryInfo(path=path,
                                  base_path=base_path,
                                  local_path=self.hg_root,
                                  supports_parent_diffs=True)
开发者ID:reviewboard,项目名称:rbtools,代码行数:31,代码来源:mercurial.py

示例11: get_repository_info

    def get_repository_info(self):
        if not check_install('hg --help'):
            return None

        self._load_hgrc()

        if not self.hg_root:
            # hg aborted => no mercurial repository here.
            return None

        svn_info = execute(["hg", "svn", "info"], ignore_errors=True)

        if (not svn_info.startswith('abort:') and
            not svn_info.startswith("hg: unknown command") and
            not svn_info.lower().startswith('not a child of')):
            return self._calculate_hgsubversion_repository_info(svn_info)

        self._type = 'hg'

        path = self.hg_root
        base_path = '/'

        if self.hgrc:
            self._calculate_remote_path()

            if self._remote_path:
                path = self._remote_path[1]
                base_path = ''

        return RepositoryInfo(path=path, base_path=base_path,
                              supports_parent_diffs=True)
开发者ID:jerboaa,项目名称:rbtools,代码行数:31,代码来源:mercurial.py

示例12: get_repository_info

    def get_repository_info(self):
        if not check_install('p4 help'):
            return None

        data = execute(["p4", "info"], ignore_errors=True)

        m = re.search(r'^Server address: (.+)$', data, re.M)
        if not m:
            return None

        repository_path = m.group(1).strip()

        try:
            hostname, port = repository_path.split(":")
            info = socket.gethostbyaddr(hostname)

            # If aliases exist for hostname, create a list of alias:port
            # strings for repository_path.
            if info[1]:
                servers = [info[0]] + info[1]
                repository_path = ["%s:%s" % (server, port)
                                   for server in servers]
            else:
                repository_path = "%s:%s" % (info[0], port)
        except (socket.gaierror, socket.herror):
            pass

        m = re.search(r'^Server version: [^ ]*/([0-9]+)\.([0-9]+)/[0-9]+ .*$',
                      data, re.M)
        self.p4d_version = int(m.group(1)), int(m.group(2))

        return RepositoryInfo(path=repository_path, supports_changesets=True)
开发者ID:flowblok,项目名称:rbtools,代码行数:32,代码来源:perforce.py

示例13: get_repository_info

    def get_repository_info(self):
        if self._svn_repository_info_cache:
            return self._svn_repository_info_cache

        if not check_install(['svn', 'help']):
            logging.debug('Unable to execute "svn help": skipping SVN')
            return None

        # Get the SVN repository path (either via a working copy or
        # a supplied URI)
        svn_info_params = ["info"]

        if getattr(self.options, 'repository_url', None):
            svn_info_params.append(self.options.repository_url)

        data = self._run_svn(svn_info_params, ignore_errors=True,
                             results_unicode=False,
                             log_output_on_error=False)

        m = re.search(b'^Repository Root: (.+)$', data, re.M)
        if not m:
            return None

        path = m.group(1)

        m = re.search(b'^URL: (.+)$', data, re.M)
        if not m:
            return None

        base_path = m.group(1)[len(path):] or b'/'

        m = re.search(b'^Repository UUID: (.+)$', data, re.M)
        if not m:
            return None

        uuid = m.group(1)

        # Now that we know it's SVN, make sure we have GNU diff installed,
        # and error out if we don't.
        check_gnu_diff()

        # Grab version of SVN client and store as a tuple in the form:
        #   (major_version, minor_version, micro_version)
        ver_string = self._run_svn(['--version', '-q'], ignore_errors=True)
        m = self.VERSION_NUMBER_RE.match(ver_string)

        if not m:
            logging.warn('Unable to parse SVN client version triple from '
                         '"%s". Assuming version 0.0.0.'
                         % ver_string.strip())
            self.subversion_client_version = (0, 0, 0)
        else:
            self.subversion_client_version = tuple(map(int, m.groups()))

        self._svn_repository_info_cache = SVNRepositoryInfo(path,
                                                            base_path,
                                                            uuid)

        return self._svn_repository_info_cache
开发者ID:clach04,项目名称:rbtools,代码行数:59,代码来源:svn.py

示例14: get_repository_info

    def get_repository_info(self):
        """Returns information on the Clear Case repository.

        This will first check if the cleartool command is
        installed and in the path, and post-review was run
        from inside of the view.
        """
        if not check_install('cleartool help'):
            return None

        viewname = execute(["cleartool", "pwv", "-short"]).strip()
        if viewname.startswith('** NONE'):
            return None

        # Now that we know it's ClearCase, make sure we have GNU diff installed,
        # and error out if we don't.
        check_gnu_diff()

        property_lines = execute(["cleartool", "lsview", "-full", "-properties",
                                  "-cview"], split_lines=True)
        for line in property_lines:
            properties = line.split(' ')
            if properties[0] == 'Properties:':
                # Determine the view type and check if it's supported.
                #
                # Specifically check if webview was listed in properties
                # because webview types also list the 'snapshot'
                # entry in properties.
                if 'webview' in properties:
                    die("Webviews are not supported. You can use post-review"
                        " only in dynamic or snapshot view.")
                if 'dynamic' in properties:
                    self.viewtype = 'dynamic'
                else:
                    self.viewtype = 'snapshot'

                break

        # Find current VOB's tag
        vobstag = execute(["cleartool", "describe", "-short", "vob:."],
                            ignore_errors=True).strip()
        if "Error: " in vobstag:
            die("To generate diff run post-review inside vob.")

        # From current working directory cut path to VOB.
        # VOB's tag contain backslash character before VOB's name.
        # I hope that first character of VOB's tag like '\new_proj'
        # won't be treat as new line character but two separate:
        # backslash and letter 'n'
        cwd = os.getcwd()
        base_path = cwd[:cwd.find(vobstag) + len(vobstag)]

        return ClearCaseRepositoryInfo(path=base_path,
                              base_path=base_path,
                              vobstag=vobstag,
                              supports_parent_diffs=False)
开发者ID:PlasticSCM,项目名称:rbtools,代码行数:56,代码来源:clearcase.py

示例15: __init__

    def __init__(self, config=None, options=None):
        super(TFSClient, self).__init__(config, options)

        self.tf = None

        if sys.platform.startswith('win'):
            # First check in the system path. If that doesn't work, look in the
            # two standard install locations.
            tf_locations = [
                'tf.cmd',
                r'%programfiles(x86)%\Microsoft Visual Studio 12.0\Common7\IDE\tf.cmd',
                r'%programfiles%\Microsoft Team Foundation Server 12.0\Tools\tf.cmd',
            ]

            for location in tf_locations:
                if check_install([location, 'help']):
                    self.tf = location
                    break
        elif check_install(['tf', 'help']):
            self.tf = 'tf'
开发者ID:acres-com-au,项目名称:rbtools,代码行数:20,代码来源:tfs.py


注:本文中的rbtools.utils.checks.check_install函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。