当前位置: 首页>>代码示例>>Python>>正文


Python ConnMan.put方法代码示例

本文整理汇总了Python中ConnMan.ConnMan.put方法的典型用法代码示例。如果您正苦于以下问题:Python ConnMan.put方法的具体用法?Python ConnMan.put怎么用?Python ConnMan.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnMan.ConnMan的用法示例。


在下文中一共展示了ConnMan.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: send_request

# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import put [as 别名]
 def send_request(self, request, body = None, retries = _max_retries):
     method_string, resource, headers = request.get_triplet()
     debug("Processing request, please wait...")
     if not headers.has_key('content-length'):
         headers['content-length'] = body and len(body) or 0
     try:
         # "Stringify" all headers
         for header in headers.keys():
             headers[header] = str(headers[header])
         conn = ConnMan.get(self.get_hostname(resource['bucket']))
         uri = self.format_uri(resource)
         debug("Sending request method_string=%r, uri=%r, headers=%r, body=(%i bytes)" % (method_string, uri, headers, len(body or "")))
         conn.c.request(method_string, uri, body, headers)
         response = {}
         http_response = conn.c.getresponse()
         response["status"] = http_response.status
         response["reason"] = http_response.reason
         response["headers"] = convertTupleListToDict(http_response.getheaders())
         response["data"] =  http_response.read()
         if response["headers"].has_key("x-amz-meta-s3cmd-attrs"):
             attrs = parse_attrs_header(response["headers"]["x-amz-meta-s3cmd-attrs"])
             response["s3cmd-attrs"] = attrs
         debug("Response: " + str(response))
         ConnMan.put(conn)
     except ParameterError, e:
         raise
开发者ID:jmehnle,项目名称:s3cmd,代码行数:28,代码来源:S3.py

示例2: send_request

# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import put [as 别名]
    def send_request(self, op_name, dist_id = None, request_id = None, body = None, headers = {}, retries = _max_retries):
        operation = self.operations[op_name]
        if body:
            headers['content-type'] = 'text/plain'
        request = self.create_request(operation, dist_id, request_id, headers)
        conn = self.get_connection()
        debug("send_request(): %s %s" % (request['method'], request['resource']))
        conn.c.request(request['method'], request['resource'], body, request['headers'])
        http_response = conn.c.getresponse()
        response = {}
        response["status"] = http_response.status
        response["reason"] = http_response.reason
        response["headers"] = dict(http_response.getheaders())
        response["data"] =  http_response.read()
        ConnMan.put(conn)

        debug("CloudFront: response: %r" % response)

        if response["status"] >= 500:
            e = CloudFrontError(response)
            if retries:
                warning(u"Retrying failed request: %s" % op_name)
                warning(unicode(e))
                warning("Waiting %d sec..." % self._fail_wait(retries))
                time.sleep(self._fail_wait(retries))
                return self.send_request(op_name, dist_id, body, retries = retries - 1)
            else:
                raise e

        if response["status"] < 200 or response["status"] > 299:
            raise CloudFrontError(response)

        return response
开发者ID:xrage,项目名称:s3cmd,代码行数:35,代码来源:CloudFront.py

示例3: len

# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import put [as 别名]
         md5_hash.update(data)
         conn.c.send(data)
         if self.config.progress_meter:
             progress.update(delta_position = len(data))
         size_left -= len(data)
         if throttle:
             time.sleep(throttle)
     md5_computed = md5_hash.hexdigest()
     response = {}
     http_response = conn.c.getresponse()
     response["status"] = http_response.status
     response["reason"] = http_response.reason
     response["headers"] = convertTupleListToDict(http_response.getheaders())
     response["data"] = http_response.read()
     response["size"] = size_total
     ConnMan.put(conn)
     debug(u"Response: %s" % response)
 except ParameterError, e:
     raise
 except Exception, e:
     if self.config.progress_meter:
         progress.done("failed")
     if retries:
         if retries < self._max_retries:
             throttle = throttle and throttle * 5 or 0.01
         warning("Upload failed: %s (%s)" % (resource['uri'], e))
         warning("Retrying on lower speed (throttle=%0.2f)" % throttle)
         warning("Waiting %d sec..." % self._fail_wait(retries))
         time.sleep(self._fail_wait(retries))
         # Connection error -> same throttle value
         return self.send_file(request, file, labels, buffer, throttle, retries - 1, offset, chunk_size)
开发者ID:jmehnle,项目名称:s3cmd,代码行数:33,代码来源:S3.py


注:本文中的ConnMan.ConnMan.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。