pycarwings2.py 文件源码

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

项目:pycarwings2 作者: jdhorne 项目源码 文件源码
def _request(self, endpoint, params):
        params["initial_app_strings"] = "geORNtsZe5I4lRGjG9GZiA"
        if self.custom_sessionid:
            params["custom_sessionid"] = self.custom_sessionid
        else:
            params["custom_sessionid"] = ""

        req = Request('POST', url=BASE_URL + endpoint, data=params).prepare()

        log.debug("invoking carwings API: %s" % req.url)
        log.debug("params: %s" % json.dumps(params, sort_keys=True, indent=3, separators=(',', ': ')))

        try:
            sess = requests.Session()
            response = sess.send(req)
            log.debug('Response HTTP Status Code: {status_code}'.format(
                status_code=response.status_code))
            log.debug('Response HTTP Response Body: {content}'.format(
                content=response.content))
        except RequestException:
            log.warning('HTTP Request failed')

        j = json.loads(response.content)

        if "message" in j and j["message"] == "INVALID PARAMS":
            log.error("carwings error %s: %s" % (j["message"], j["status"]) )
            raise CarwingsError("INVALID PARAMS")
        if "ErrorMessage" in j:
            log.error("carwings error %s: %s" % (j["ErrorCode"], j["ErrorMessage"]) )
            raise CarwingsError

        return j
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号