anita.py 文件源码

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

项目:anita 作者: gson1703 项目源码 文件源码
def shell_cmd(child, cmd, timeout = -1):
    child.send("exec /bin/sh\n")
    child.expect("# ")
    prompt = gen_shell_prompt()
    child.send("PS1=" + quote_prompt(prompt) + "\n")
    prompt_re = prompt
    child.expect(prompt_re)
    child.send(cmd + "\n")
    # Catch EOF to log the signalstatus, to help debug qemu crashes
    try:
        child.expect(prompt_re, timeout)
    except pexpect.EOF:
        print "pexpect reported EOF - VMM exited unexpectedly"
        child.close()
        print "exitstatus", child.exitstatus
        print "signalstatus", child.signalstatus
        raise
    except:
        raise
    child.send("echo exit_status=$?=\n")
    child.expect("exit_status=(\d+)=")
    r = int(child.match.group(1))
    child.expect(prompt_re, timeout)
    return r
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号