本文整理汇总了Python中ConnMan.ConnMan.get方法的典型用法代码示例。如果您正苦于以下问题:Python ConnMan.get方法的具体用法?Python ConnMan.get怎么用?Python ConnMan.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnMan.ConnMan
的用法示例。
在下文中一共展示了ConnMan.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: recv_file
# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import get [as 别名]
def recv_file(self, request, stream, labels, start_position = 0, retries = _max_retries):
method_string, resource, headers = request.get_triplet()
if self.config.progress_meter:
progress = self.config.progress_class(labels, 0)
else:
info("Receiving file '%s', please wait..." % stream.name)
timestamp_start = time.time()
try:
conn = ConnMan.get(self.get_hostname(resource['bucket']))
conn.c.putrequest(method_string, self.format_uri(resource))
for header in headers.keys():
conn.c.putheader(header, str(headers[header]))
if start_position > 0:
debug("Requesting Range: %d .. end" % start_position)
conn.c.putheader("Range", "bytes=%d-" % start_position)
conn.c.endheaders()
response = {}
http_response = conn.c.getresponse()
response["status"] = http_response.status
response["reason"] = http_response.reason
response["headers"] = convertTupleListToDict(http_response.getheaders())
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: %s" % response)
except ParameterError, e:
raise
示例2: send_request
# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import get [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
示例3: send_file
# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import get [as 别名]
def send_file(self, request, file, labels, buffer = '', throttle = 0, retries = _max_retries, offset = 0, chunk_size = -1):
method_string, resource, headers = request.get_triplet()
print method_string
print resource
print headers
print "File size is " + str(file.content_length)
data = file.stream.read()
#data = ':'.join(format(ord(c), 'b') for c in file.stream.read())
size_left = size_total = len(data)
print " I am inb here"
if self.config.progress_meter:
progress = self.config.progress_class(labels, size_total)
else:
info("Sending file '%s', please wait..." % file.name)
timestamp_start = time.time()
try:
conn = ConnMan.get(self.get_hostname(resource['bucket']))
conn.c.putrequest(method_string, self.format_uri(resource))
print dir(file)
headers['content-length'] = len(data)
#headers['content-type'] = 'binary/octet-stream'
for header in headers.keys():
print " Trying to print header"
print header + " : " + str(headers[header])
conn.c.putheader(header, str(headers[header]))
conn.c.endheaders()
except ParameterError, e:
raise
示例4: send_file
# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import get [as 别名]
def send_file(self, request, file, labels, buffer = '', throttle = 0, retries = _max_retries, offset = 0, chunk_size = -1):
method_string, resource, headers = request.get_triplet()
size_left = size_total = headers.get("content-length")
if self.config.progress_meter:
progress = self.config.progress_class(labels, size_total)
else:
info("Sending file '%s', please wait..." % file.name)
timestamp_start = time.time()
try:
conn = ConnMan.get(self.get_hostname(resource['bucket']))
conn.c.putrequest(method_string, self.format_uri(resource))
for header in headers.keys():
conn.c.putheader(header, str(headers[header]))
conn.c.endheaders()
except ParameterError, e:
raise
示例5: get_connection
# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import get [as 别名]
def get_connection(self):
if self.config.proxy_host != "":
raise ParameterError("CloudFront commands don't work from behind a HTTP proxy")
conn = ConnMan.get(self.config.cloudfront_host)
return conn
示例6: get_connection
# 需要导入模块: from ConnMan import ConnMan [as 别名]
# 或者: from ConnMan.ConnMan import get [as 别名]
def get_connection(self):
conn = ConnMan.get(self.config.cloudfront_host, ssl = True)
return conn