本文整理汇总了Python中swift.common.utils.csv_append函数的典型用法代码示例。如果您正苦于以下问题:Python csv_append函数的具体用法?Python csv_append怎么用?Python csv_append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了csv_append函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _backend_requests
def _backend_requests(self, req, n_outgoing,
container_partition, containers,
delete_at_partition=None, delete_at_nodes=None):
headers = [dict(req.headers.iteritems())
for _junk in range(n_outgoing)]
for header in headers:
header['Connection'] = 'close'
for i, container in enumerate(containers):
i = i % len(headers)
headers[i]['X-Container-Partition'] = container_partition
headers[i]['X-Container-Host'] = csv_append(
headers[i].get('X-Container-Host'),
'%(ip)s:%(port)s' % container)
headers[i]['X-Container-Device'] = csv_append(
headers[i].get('X-Container-Device'),
container['device'])
for i, node in enumerate(delete_at_nodes or []):
i = i % len(headers)
headers[i]['X-Delete-At-Partition'] = delete_at_partition
headers[i]['X-Delete-At-Host'] = csv_append(
headers[i].get('X-Delete-At-Host'),
'%(ip)s:%(port)s' % node)
headers[i]['X-Delete-At-Device'] = csv_append(
headers[i].get('X-Delete-At-Device'),
node['device'])
return headers
示例2: _sof_container_update
def _sof_container_update(self, request, resp):
"""
SOF specific metadata is set in DiskFile.open()._filter_metadata()
This method internally invokes Swift's container_update() method.
"""
device, partition, account, container, obj, policy_idx = \
get_name_and_placement(request, 5, 5, True)
# The container_update() method requires certain container
# specific headers. The proxy object controller appends these
# headers for PUT backend request but not for HEAD/GET requests.
# Thus, we populate the required information in request
# and then invoke container_update()
container_partition, container_nodes = \
self.get_container_ring().get_nodes(account, container)
request.headers['X-Container-Partition'] = container_partition
for node in container_nodes:
request.headers['X-Container-Host'] = csv_append(
request.headers.get('X-Container-Host'),
'%(ip)s:%(port)s' % node)
request.headers['X-Container-Device'] = csv_append(
request.headers.get('X-Container-Device'), node['device'])
self.container_update(
'PUT', account, container, obj, request,
HeaderKeyDict({
'x-size': resp.headers['Content-Length'],
'x-content-type': resp.headers['Content-Type'],
'x-timestamp': resp.headers['X-Timestamp'],
'x-etag': resp.headers['ETag']}),
device, policy_idx)
示例3: _backend_requests
def _backend_requests(self, req, n_outgoing,
container_partition, containers,
delete_at_container=None, delete_at_partition=None,
delete_at_nodes=None):
headers = [self.generate_request_headers(req, additional=req.headers)
for _junk in range(n_outgoing)]
for i, container in enumerate(containers):
i = i % len(headers)
headers[i]['X-Container-Partition'] = container_partition
headers[i]['X-Container-Host'] = csv_append(
headers[i].get('X-Container-Host'),
'%(ip)s:%(port)s' % container)
headers[i]['X-Container-Device'] = csv_append(
headers[i].get('X-Container-Device'),
container['device'])
for i, node in enumerate(delete_at_nodes or []):
i = i % len(headers)
headers[i]['X-Delete-At-Container'] = delete_at_container
headers[i]['X-Delete-At-Partition'] = delete_at_partition
headers[i]['X-Delete-At-Host'] = csv_append(
headers[i].get('X-Delete-At-Host'),
'%(ip)s:%(port)s' % node)
headers[i]['X-Delete-At-Device'] = csv_append(
headers[i].get('X-Delete-At-Device'),
node['device'])
return headers
示例4: _backend_requests
def _backend_requests(
self,
req,
n_outgoing,
container_partition,
containers,
delete_at_container=None,
delete_at_partition=None,
delete_at_nodes=None,
):
headers = [self.generate_request_headers(req, additional=req.headers) for _junk in range(n_outgoing)]
for header in headers:
header["Connection"] = "close"
for i, container in enumerate(containers):
i = i % len(headers)
headers[i]["X-Container-Partition"] = container_partition
headers[i]["X-Container-Host"] = csv_append(
headers[i].get("X-Container-Host"), "%(ip)s:%(port)s" % container
)
headers[i]["X-Container-Device"] = csv_append(headers[i].get("X-Container-Device"), container["device"])
for i, node in enumerate(delete_at_nodes or []):
i = i % len(headers)
headers[i]["X-Delete-At-Container"] = delete_at_container
headers[i]["X-Delete-At-Partition"] = delete_at_partition
headers[i]["X-Delete-At-Host"] = csv_append(headers[i].get("X-Delete-At-Host"), "%(ip)s:%(port)s" % node)
headers[i]["X-Delete-At-Device"] = csv_append(headers[i].get("X-Delete-At-Device"), node["device"])
return headers
示例5: _backend_requests
def _backend_requests(self, req, n_outgoing, account_partition, accounts):
headers = [self.generate_request_headers(req, transfer=True) for _junk in range(n_outgoing)]
for i, account in enumerate(accounts):
i = i % len(headers)
headers[i]["X-Account-Partition"] = account_partition
headers[i]["X-Account-Host"] = csv_append(headers[i].get("X-Account-Host"), "%(ip)s:%(port)s" % account)
headers[i]["X-Account-Device"] = csv_append(headers[i].get("X-Account-Device"), account["device"])
return headers
示例6: _backend_requests
def _backend_requests(self, req, n_outgoing, account_partition, accounts, policy_index=None):
additional = {"X-Timestamp": Timestamp(time.time()).internal}
if policy_index is None:
additional["X-Backend-Storage-Policy-Default"] = int(POLICIES.default)
else:
additional["X-Backend-Storage-Policy-Index"] = str(policy_index)
headers = [
self.generate_request_headers(req, transfer=True, additional=additional) for _junk in range(n_outgoing)
]
for i, account in enumerate(accounts):
i = i % len(headers)
headers[i]["X-Account-Partition"] = account_partition
headers[i]["X-Account-Host"] = csv_append(headers[i].get("X-Account-Host"), "%(ip)s:%(port)s" % account)
headers[i]["X-Account-Device"] = csv_append(headers[i].get("X-Account-Device"), account["device"])
return headers
示例7: _backend_requests
def _backend_requests(self, req, n_outgoing,
account_partition, accounts):
additional = {'X-Timestamp': normalize_timestamp(time.time())}
headers = [self.generate_request_headers(req, transfer=True,
additional=additional)
for _junk in range(n_outgoing)]
for i, account in enumerate(accounts):
i = i % len(headers)
headers[i]['X-Account-Partition'] = account_partition
headers[i]['X-Account-Host'] = csv_append(
headers[i].get('X-Account-Host'),
'%(ip)s:%(port)s' % account)
headers[i]['X-Account-Device'] = csv_append(
headers[i].get('X-Account-Device'),
account['device'])
return headers
示例8: _backend_requests
def _backend_requests(self, req, n_outgoing,
account_partition, accounts):
headers = [{'Connection': 'close',
'X-Timestamp': normalize_timestamp(time.time()),
'x-trans-id': self.trans_id}
for _junk in range(n_outgoing)]
for header in headers:
self.transfer_headers(req.headers, header)
for i, account in enumerate(accounts):
i = i % len(headers)
headers[i]['X-Account-Partition'] = account_partition
headers[i]['X-Account-Host'] = csv_append(
headers[i].get('X-Account-Host'),
'%(ip)s:%(port)s' % account)
headers[i]['X-Account-Device'] = csv_append(
headers[i].get('X-Account-Device'),
account['device'])
return headers
示例9: _backend_requests
def _backend_requests(self, req, n_outgoing, account_partition, accounts,
policy_index=None):
additional = {'X-Timestamp': Timestamp.now().internal}
if policy_index is None:
additional['X-Backend-Storage-Policy-Default'] = \
int(POLICIES.default)
else:
additional['X-Backend-Storage-Policy-Index'] = str(policy_index)
headers = [self.generate_request_headers(req, transfer=True,
additional=additional)
for _junk in range(n_outgoing)]
for i, account in enumerate(accounts):
i = i % len(headers)
headers[i]['X-Account-Partition'] = account_partition
headers[i]['X-Account-Host'] = csv_append(
headers[i].get('X-Account-Host'),
'%(ip)s:%(port)s' % account)
headers[i]['X-Account-Device'] = csv_append(
headers[i].get('X-Account-Device'),
account['device'])
return headers
示例10: update_etag_is_at_header
def update_etag_is_at_header(req, name):
"""
Helper function to update an X-Backend-Etag-Is-At header whose value is a
list of alternative header names at which the actual object etag may be
found. This informs the object server where to look for the actual object
etag when processing conditional requests.
Since the proxy server and/or middleware may set alternative etag header
names, the value of X-Backend-Etag-Is-At is a comma separated list which
the object server inspects in order until it finds an etag value.
:param req: a swob Request
:param name: name of a sysmeta where alternative etag may be found
"""
if "," in name:
# HTTP header names should not have commas but we'll check anyway
raise ValueError("Header name must not contain commas")
existing = req.headers.get("X-Backend-Etag-Is-At")
req.headers["X-Backend-Etag-Is-At"] = csv_append(existing, name)