client.py 文件源码

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

项目:tornetcd 作者: mqingyn 项目源码 文件源码
def api_execute(self, path, method, params=None, timeout=None):
        """ Executes the query. """
        url = self._base_url + path

        validate_cert = True if self.cert_options else False
        if (method == self._MGET) or (method == self._MDELETE):
            if params:
                url = url_concat(url, params)
            body = None

        elif (method == self._MPUT) or (method == self._MPOST):
            body = urlencode(params)

        else:
            raise etcdexcept.EtcdException(
                    'HTTP method {} not supported'.format(method))
        request = HTTPRequest(url, method=method,
                              request_timeout=timeout,
                              headers=self._get_default_headers(method),
                              follow_redirects=self.allow_redirect,
                              body=body,
                              validate_cert=validate_cert,
                              ca_certs=self.cert_options.get('ca_certs', None),
                              client_key=self.cert_options.get('client_key', None),
                              client_cert=self.cert_options.get('client_cert', None),
                              auth_username=self.username,
                              auth_password=self.password)
        _log.debug("Request %s %s %s" % (path, method, request.body))
        return self.http.fetch(request)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号