• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python subprocutils.check_output函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _is_buckd_running

    def _is_buckd_running(self):
        with Tracing('BuckRepo._is_buckd_running'):
            buckd_socket_path = self._buck_project.get_buckd_socket_path()

            if not os.path.exists(buckd_socket_path):
                return False

            buck_client_file = self._get_resource(CLIENT)
            command = [buck_client_file]
            command.append('ng-stats')
            command.append('--nailgun-server')
            command.append('local:.buckd/sock')
            try:
                check_output(
                    command,
                    cwd=self._buck_project.root,
                    stderr=subprocess.STDOUT)
            except CalledProcessError as e:
                if e.returncode == NAILGUN_CONNECTION_REFUSED_CODE:
                    return False
                else:
                    print(e.output, end='', file=sys.stderr)
                    raise

            return True
开发者ID:CocoaHoo,项目名称:buck,代码行数:25,代码来源:buck_tool.py


示例2: get_dirty_buck_version

def get_dirty_buck_version(dirpath):
    git_tree_in = check_output(
        ['git', 'log', '-n1', '--pretty=format:%T', 'HEAD', '--'],
        cwd=dirpath).strip()

    with EmptyTempFile(prefix='buck-git-index') as index_file:
        new_environ = os.environ.copy()
        new_environ['GIT_INDEX_FILE'] = index_file.name
        subprocess.check_call(
            ['git', 'read-tree', git_tree_in],
            cwd=dirpath,
            env=new_environ)

        subprocess.check_call(
            ['git', 'add', '-A'],
            cwd=dirpath,
            env=new_environ)

        git_tree_out = check_output(
            ['git', 'write-tree'],
            cwd=dirpath,
            env=new_environ).strip()

    with EmptyTempFile(prefix='buck-version-uid-input',
                       closed=False) as uid_input:
        subprocess.check_call(
            ['git', 'ls-tree', '--full-tree', git_tree_out],
            cwd=dirpath,
            stdout=uid_input)
        return check_output(
            ['git', 'hash-object', uid_input.name],
            cwd=dirpath).strip()
开发者ID:292388900,项目名称:buck,代码行数:32,代码来源:buck_version.py


示例3: _setup_watchman_watch

    def _setup_watchman_watch(self):
        with Tracing('BuckRepo._setup_watchman_watch'):
            if not which('watchman'):
                message = textwrap.dedent("""\
                    Watchman not found, please install when using buckd.
                    See https://github.com/facebook/watchman for details.""")
                if sys.platform == "darwin":
                    message += "\n(brew install watchman on OS X)"
                # Bail if watchman isn't installed as we know java's
                # FileSystemWatcher will take too long to process events.
                raise BuckToolException(message)

            print("Using watchman.", file=sys.stderr)
            try:
                # Check watchman version
                # We only want to use watch-project in watchman >= 3.4,
                # since early versions don't return the project path relative to
                # the repo root.
                if self._watchman_atleast(3, 4):
                    response = check_output(
                        ['watchman', 'watch-project', self._buck_project.root],
                        stderr=subprocess.STDOUT)
                else:
                    response = check_output(
                        ['watchman', 'watch', self._buck_project.root],
                        stderr=subprocess.STDOUT)

                jsonresp = json.loads(response)
                root = jsonresp.get("watch", self._buck_project.root)
                relative_path = jsonresp.get('relative_path')
                return root, relative_path
            except CalledProcessError as e:
                print(e.output, end='', file=sys.stderr)
                raise
开发者ID:rami-khalil,项目名称:buck,代码行数:34,代码来源:buck_tool.py


示例4: kill_buckd

    def kill_buckd(self):
        with Tracing('BuckRepo.kill_buckd'):
            buckd_port = self._buck_project.get_buckd_port()

            if buckd_port:
                if not buckd_port.isdigit():
                    print("WARNING: Corrupt buckd port: '{0}'.".format(buckd_port))
                else:
                    print("Shutting down nailgun server...", file=sys.stderr)
                    buck_client_file = self._get_resource(CLIENT)
                    command = [buck_client_file]
                    command.append('ng-stop')
                    command.append('--nailgun-port')
                    command.append(buckd_port)
                    try:
                        check_output(
                            command,
                            cwd=self._buck_project.root,
                            stderr=subprocess.STDOUT)
                    except CalledProcessError as e:
                        if (e.returncode not in
                                [NAILGUN_CONNECTION_REFUSED_CODE,
                                    NAILGUN_CONNECTION_BROKEN_CODE,
                                    NAILGUN_UNEXPECTED_CHUNK_TYPE]):
                            print(e.output, end='', file=sys.stderr)
                            raise

            self._buck_project.clean_up_buckd()
开发者ID:LBSHackathon,项目名称:buck,代码行数:28,代码来源:buck_tool.py


示例5: _is_buckd_running

    def _is_buckd_running(self):
        with Tracing('BuckRepo._is_buckd_running'):
            buckd_port = self._buck_project.get_buckd_port()

            if buckd_port is None or not buckd_port.isdigit():
                return False

            buck_client_file = self._get_resource(CLIENT)
            command = [buck_client_file]
            command.append('ng-stats')
            command.append('--nailgun-port')
            command.append(buckd_port)
            try:
                check_output(
                    command,
                    cwd=self._buck_project.root,
                    stderr=subprocess.STDOUT)
            except CalledProcessError as e:
                if e.returncode == NAILGUN_CONNECTION_REFUSED_CODE:
                    return False
                else:
                    print(e.output, end='', file=sys.stderr)
                    raise

            return True
开发者ID:LBSHackathon,项目名称:buck,代码行数:25,代码来源:buck_tool.py


示例6: get_dirty_buck_version

def get_dirty_buck_version(dirpath):
    git_tree_in = check_output(["git", "log", "-n1", "--pretty=format:%T", "HEAD", "--"], cwd=dirpath).strip()

    with EmptyTempFile(prefix="buck-git-index") as index_file:
        new_environ = os.environ.copy()
        new_environ["GIT_INDEX_FILE"] = index_file.name
        subprocess.check_call(["git", "read-tree", git_tree_in], cwd=dirpath, env=new_environ)

        subprocess.check_call(["git", "add", "-A"], cwd=dirpath, env=new_environ)

        git_tree_out = check_output(["git", "write-tree"], cwd=dirpath, env=new_environ).strip()

    with EmptyTempFile(prefix="buck-version-uid-input", closed=False) as uid_input:
        subprocess.check_call(["git", "ls-tree", "--full-tree", git_tree_out], cwd=dirpath, stdout=uid_input)
        return check_output(["git", "hash-object", uid_input.name], cwd=dirpath).strip()
开发者ID:sdwilsh,项目名称:buck,代码行数:15,代码来源:buck_version.py


示例7: _has_local_changes

    def _has_local_changes(self):
        if not self.is_git:
            return False

        output = check_output(
            ['git', 'ls-files', '-m'],
            cwd=self.buck_dir)
        return bool(output.strip())
开发者ID:dsyang,项目名称:buck,代码行数:8,代码来源:buck_repo.py


示例8: is_git

def is_git(dirpath):
    dot_git = os.path.join(dirpath, ".git")
    if which("git") and sys.platform != "cygwin":
        if os.path.exists(dot_git) and os.path.isdir(dot_git):
            return True
        output = check_output(["git", "rev-parse", "--is-inside-work-tree"], cwd=dirpath)
        return output.strip() == "true"
    return False
开发者ID:sdwilsh,项目名称:buck,代码行数:8,代码来源:buck_version.py


示例9: is_java8

def is_java8():
    try:
        output = check_output(['java', '-version'], stderr=subprocess.STDOUT)
        version_line = output.strip().splitlines()[0]
        return re.compile('(openjdk|java) version "1\.8\..*').match(version_line)
    except CalledProcessError as e:
        print(e.output, file=sys.stderr)
        raise e
开发者ID:CocoaHoo,项目名称:buck,代码行数:8,代码来源:buck_tool.py


示例10: _watchman_atleast

 def _watchman_atleast(self, major, minor):
     """Returns true if the installed watchman is greater than or equal to
     the given version."""
     response = check_output(['watchman', 'version'])
     version = json.loads(response).get("version")
     parts = version.split('.')
     actualmajor = int(parts[0])
     actualminor = int(parts[1])
     return actualmajor > major or (actualmajor == major and
                                    actualminor >= minor)
开发者ID:rami-khalil,项目名称:buck,代码行数:10,代码来源:buck_tool.py


示例11: _setup_watchman_watch

    def _setup_watchman_watch(self):
        with Tracing('BuckRepo._setup_watchman_watch'):
            if not which('watchman'):
                message = textwrap.dedent("""\
                    Watchman not found, please install when using buckd.
                    See https://github.com/facebook/watchman for details.""")
                if sys.platform == "darwin":
                    message += "\n(brew install watchman on OS X)"
                # Bail if watchman isn't installed as we know java's
                # FileSystemWatcher will take too long to process events.
                raise BuckToolException(message)

            print("Using watchman.", file=sys.stderr)
            try:
                check_output(
                    ['watchman', 'watch', self._buck_project.root],
                    stderr=subprocess.STDOUT)
            except CalledProcessError as e:
                print(e.output, end='', file=sys.stderr)
                raise
开发者ID:LBSHackathon,项目名称:buck,代码行数:20,代码来源:buck_tool.py


示例12: is_dirty

def is_dirty(dirpath):
    # Ignore any changes under these paths for the purposes of forcing a rebuild
    # of Buck itself.
    IGNORE_PATHS = ["test"]
    IGNORE_PATHS_RE_GROUP = "|".join([re.escape(e) for e in IGNORE_PATHS])
    IGNORE_PATHS_RE = re.compile("^.. (?:" + IGNORE_PATHS_RE_GROUP + ")")

    if not is_git(dirpath):
        return False

    output = check_output(["git", "status", "--porcelain"], cwd=dirpath)
    output = "\n".join([line for line in output.splitlines() if not IGNORE_PATHS_RE.search(line)])
    return bool(output.strip())
开发者ID:sdwilsh,项目名称:buck,代码行数:13,代码来源:buck_version.py


示例13: _get_java_version

def _get_java_version():
    """
    Returns a Java version string (e.g. "7", "8").

    Information is provided by java tool and parsing is based on
    http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html
    """
    java_version = check_output(["java", "-version"], stderr=subprocess.STDOUT)
    # extract java version from a string like 'java version "1.8.0_144"'
    match = re.search("java version \"(?P<version>.+)\"", java_version)
    if not match:
        return None
    return match.group("version").split(".")[1]
开发者ID:clonetwin26,项目名称:buck,代码行数:13,代码来源:buck.py


示例14: is_java8

def is_java8():
    global _java8
    if _java8 is not None:
        return _java8
    try:
        output = check_output(['java', '-version'], stderr=subprocess.STDOUT)
        version_line = output.strip().splitlines()[0]
        m = re.compile('(openjdk|java) version "1\.8\..*').match(version_line)
        _java8 = bool(m)
        return _java8
    except CalledProcessError as e:
        print(e.output, file=sys.stderr)
        raise e
开发者ID:hardikvala,项目名称:buck,代码行数:13,代码来源:buck_tool.py


示例15: is_java8_or_9

def is_java8_or_9():
    global _java8_or_9
    if _java8_or_9 is not None:
        return _java8_or_9
    try:
        cmd = ["java", "-Xms64m", "-version"]
        output = check_output(cmd, stderr=subprocess.STDOUT)
        version_line = output.strip().splitlines()[0]
        m = re.compile('(openjdk|java) version "(1\.(8|9)\.|9).*').match(version_line)
        _java8_or_9 = bool(m)
        return _java8_or_9
    except CalledProcessError as e:
        print(e.output, file=sys.stderr)
        raise e
开发者ID:philipjameson,项目名称:buck,代码行数:14,代码来源:buck_tool.py


示例16: is_git

def is_git(dirpath):
    dot_git = os.path.join(dirpath, '.git')
    if which('git') and sys.platform != 'cygwin':
        if os.path.exists(dot_git) and os.path.isdir(dot_git):
            return True
        try:
            with open(os.devnull, 'w') as devnull:
                output = check_output(
                    ['git', 'rev-parse', '--is-inside-work-tree'],
                    cwd=dirpath,
                    stderr=devnull)
            return output.strip() == 'true'
        except CalledProcessError:
            pass
    return False
开发者ID:clonetwin26,项目名称:buck,代码行数:15,代码来源:buck_version.py


示例17: kill_buckd

    def kill_buckd(self):
        with Tracing('BuckRepo.kill_buckd'):
            buckd_socket_path = self._buck_project.get_buckd_socket_path()
            if os.path.exists(buckd_socket_path):
                print("Shutting down nailgun server...", file=sys.stderr)
                buck_client_file = self._get_resource(CLIENT)
                command = [buck_client_file]
                command.append('ng-stop')
                command.append('--nailgun-server')
                command.append("local:.buckd/sock")
                try:
                    check_output(
                        command,
                        cwd=self._buck_project.root,
                        stderr=subprocess.STDOUT)
                except CalledProcessError as e:
                    if (e.returncode not in
                        [NAILGUN_CONNECTION_REFUSED_CODE,
                         NAILGUN_CONNECTION_BROKEN_CODE,
                         NAILGUN_UNEXPECTED_CHUNK_TYPE]):
                        print(e.output, end='', file=sys.stderr)
                        raise

            self._buck_project.clean_up_buckd()
开发者ID:CocoaHoo,项目名称:buck,代码行数:24,代码来源:buck_tool.py


示例18: is_dirty

def is_dirty(dirpath):
    # Ignore any changes under these paths for the purposes of forcing a rebuild
    # of Buck itself.
    IGNORE_PATHS = ['test']
    IGNORE_PATHS_RE_GROUP = '|'.join([re.escape(e) for e in IGNORE_PATHS])
    IGNORE_PATHS_RE = re.compile('^.. (?:' + IGNORE_PATHS_RE_GROUP + ')')

    if not is_git(dirpath):
        return False

    output = check_output(
        ['git', 'status', '--porcelain'],
        cwd=dirpath)
    output = '\n'.join([line for line in output.splitlines() if not IGNORE_PATHS_RE.search(line)])
    return bool(output.strip())
开发者ID:292388900,项目名称:buck,代码行数:15,代码来源:buck_version.py


示例19: is_java8_or_9

def is_java8_or_9():
    global _java8_or_9
    if _java8_or_9 is not None:
        return _java8_or_9
    try:
        cmd = ['java', '-Xms64m', '-version']
        output = check_output(cmd, stderr=subprocess.STDOUT)
        for version_line in output.strip().splitlines():
            m = re.compile('(openjdk|java) version "(1\.(8|9)\.|9).*').match(version_line)
            if bool(m):
                return True
        return False
    except CalledProcessError as e:
        print(e.output, file=sys.stderr)
        raise e
开发者ID:raviagarwal7,项目名称:buck,代码行数:15,代码来源:buck_tool.py


示例20: _environ_for_buck

 def _environ_for_buck(self):
     env = os.environ.copy()
     env['CLASSPATH'] = str(self._get_bootstrap_classpath())
     env['BUCK_CLASSPATH'] = str(self._get_java_classpath())
     env['BUCK_TTY'] = str(int(sys.stdin.isatty()))
     if os.name == 'posix':
         # It will fallback on default on Windows platform.
         try:
             # Get the number of columns in the terminal.
             with open(os.devnull, 'w') as devnull:
                 stty_size_str = check_output(["stty", "size"], stderr=devnull).strip()
                 stty_size = stty_size_str.split(' ')
                 if len(stty_size) >= 2:
                     env['BUCK_TERM_COLUMNS'] = stty_size[1]
         except CalledProcessError:
             # If the call to tput fails, we use the default.
             pass
     return env
开发者ID:ilya-klyuchnikov,项目名称:buck,代码行数:18,代码来源:buck_tool.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python subprocutils.which函数代码示例发布时间:2022-05-27
下一篇:
Python subprocesses.normExpUserPath函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap