utils.py 文件源码

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

项目:kuberdock-platform 作者: cloudlinux 项目源码 文件源码
def ssh_exec_live(ssh, cmd, timeout=None, check_retcode=True):
    LOG.debug(u"{}Calling SSH live: '{}'{}".format(Style.DIM, cmd,
                                                   Style.RESET_ALL))
    try:
        interact = SSHClientInteraction(ssh, timeout=timeout, display=True,
                                        logger=logging.getLogger())
        interact.expect('.*')
        interact.send(cmd + "; exit $?")  # needed to not depend on prompt type
        interact.tail()
        ret_code = interact.channel.recv_exit_status()
    except Exception:
        LOG.debug("Something went wrong in 'ssh_exec_live':\n{}".format(
            format_exception(sys.exc_info())
        ))
        raise

    _proceed_exec_result("", "", ret_code, check_retcode)
    return ret_code, "", ""
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号