common.py 文件源码

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

项目:konsodi 作者: kharts 项目源码 文件源码
def JSONRPC(method, params={}):
    """
    Execute JSON-RPC method
    :param method: name of the method. Example "Input.Back"
    :type method: str
    :param params: dictionary with parameter values
    :type params: dict
    :return: response as a string or None (in case of exception)
    :rtype: str or None
    """

    data = {
        "jsonrpc": "2.0",
        "id": 1,
        "method": method,
        "params": params
    }

    command = json.dumps(data)

    try:
        response = xbmc.executeJSONRPC(command)
    except Exception, e:
        log_exception("Error executing JSON RPC method " + method)
        log_exception("Params: " + str(params))
        log_exception(str(e))
        return None
    return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号