mbinfo.py 文件源码

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

项目:btbot 作者: ipalmieri 项目源码 文件源码
def info_request(command):

    logger.debug("Making api request to " + REQUEST_HOST + REQUEST_PATH + command + '/')

    ret = None
    conn = None
    try:
        conn = httplib.HTTPSConnection(REQUEST_HOST, timeout=HTTPCON_TIMEOUT)
        conn.request('GET', REQUEST_PATH + command + '/')

        # Pre-process response
        resp = conn.getresponse()
        data = resp.read()

        # Utilizar a classe OrderedDict para preservar a ordem dos elementos
        response_json = json.loads(data, object_pairs_hook=OrderedDict)
        logger.debug("info_request status: " + str(resp.status) + " " + str(resp.reason))
    except Exception as e:
        logger.error("Failed api request: " + str(e))
    else:
        ret = response_json
    finally:
        if conn:
            conn.close()
    return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号