rspet_server_api.py 文件源码

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

项目:RSPET 作者: panagiks 项目源码 文件源码
def run_cmd_host(host_id):
    """Execute host specific command."""
    #Select host on the server.
    res = RSPET_API.select([host_id])
    #Check if host selected correctly (if not probably host_id is invalid).
    if res["code"] != rspet_server.ReturnCodes.OK:
        abort(404)
    #Read 'command' argument from query string.
    comm = request.args.get('command')
    if not comm or comm in EXCLUDED_FUNCTIONS:
        abort(400)
    try:
        #Read 'args' argument from query string.
        args = request.args.getlist('args')
        #Cast arguments to string.
        for i, val in enumerate(args):
            args[i] = str(val)
    except KeyError:
        args = []
    #Execute command.
    res = RSPET_API.call_plugin(comm, args)
    #Unselect host. Maintain statelessness of RESTful.
    RSPET_API.select()
    return jsonify(res)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号