shell.py 文件源码

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

项目:true_review_web2py 作者: lucadealfaro 项目源码 文件源码
def callback():
    app = request.args[0]
    command = request.vars.statement
    escape = command[:1] != '!'
    history = session['history:' + app] = session.get(
        'history:' + app, gluon.contrib.shell.History())
    if not escape:
        command = command[1:]
    if command == '%reset':
        reset()
        return '*** reset ***'
    elif command[0] == '%':
        try:
            command = session['commands:' + app][int(command[1:])]
        except ValueError:
            return ''
    session['commands:' + app].append(command)
    environ = env(app, True, extra_request=dict(is_https=request.is_https))
    output = gluon.contrib.shell.run(history, command, environ)
    k = len(session['commands:' + app]) - 1
    #output = PRE(output)
    #return TABLE(TR('In[%i]:'%k,PRE(command)),TR('Out[%i]:'%k,output))
    return cgi.escape('In [%i] : %s%s\n' % (k + 1, command, output))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号