__init__.py 文件源码

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

项目:theopencorps 作者: theopencorps 项目源码 文件源码
def request(self, resource, **kwargs):
        """
        Convenience for making requests

        Synchronous returns an object with status_code and content members.

        FIXME this should really return JSON to match ASync
        """
        request_args = self._create_request_args(**kwargs)
        result = urlfetch.fetch(self._endpoint + resource, **request_args)

        msg = "%s: %s%s %d (returned %d bytes)" % (
            request_args["method"], self._endpoint, resource,
            result.status_code, len(result.content))

        if result.status_code == 200:
            self.log.info(msg)
            self.log.debug("Sent: %s", repr(request_args["headers"]))
            self.log.debug("payload: %s", repr(request_args["payload"]))
            self.log.debug("Got:  %s", repr(result.content))
        else:
            self.log.warning(msg)
            self.log.info("Sent %s", repr(request_args["headers"]))
            self.log.debug("payload: %s", repr(request_args["payload"]))
            self.log.info(result.content)
        return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号