client.py 文件源码

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

项目:aliyun-sms 作者: wilslee 项目源码 文件源码
def do_action_with_exception(self, acs_request):

        # set server response format as json, because thie function will
        # parse the response so which format doesn't matter
        acs_request.set_accept_format('json')

        status, headers, body = self._implementation_of_do_action(acs_request)

        request_id = None
        ret = body

        try:
            body_obj = json.loads(body.decode('utf-8'))
            request_id = body_obj.get('RequestId')
            ret = body_obj
        except ValueError:
            # in case the response body is not a json string, return the raw data instead
            pass

        if status != http.client.OK:
            server_error_code, server_error_message = self._parse_error_info_from_response_body(body)
            raise ServerException(server_error_code, server_error_message, http_status=status, request_id=request_id)

        return body
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号