pstorage.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:kuberdock-platform 作者: cloudlinux 项目源码 文件源码
def execute_run(command, timeout=NODE_COMMAND_TIMEOUT, jsonresult=False,
                catch_exitcodes=None):
    try:
        result = run(command, timeout=timeout)
    except (CommandTimeout, NetworkError):
        raise NodeCommandTimeoutError(
            'Timeout reached while execute remote command'
        )
    if result.return_code != 0:
        if not catch_exitcodes or result.return_code not in catch_exitcodes:
            raise NodeCommandError(
                'Remote command `{0}` execution failed (exit code = {1})'
                .format(command, result.return_code)
            )
        raise NodeCommandWrongExitCode(code=result.return_code)
    if jsonresult:
        try:
            result = json.loads(result)
        except (ValueError, TypeError):
            raise NodeCommandError(
                u'Invalid json output of remote command: {}'.format(result))
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号