Encountered when using "s3cmd info" directly on a bucket.
Florent Viard authored on 2020/04/20 23:34:08... | ... |
@@ -460,10 +460,14 @@ class S3(object): |
460 | 460 |
return location |
461 | 461 |
|
462 | 462 |
def get_bucket_requester_pays(self, uri): |
463 |
- request = self.create_request("BUCKET_LIST", bucket = uri.bucket(), |
|
464 |
- uri_params = {'requestPayment': None}) |
|
463 |
+ request = self.create_request("BUCKET_LIST", bucket=uri.bucket(), |
|
464 |
+ uri_params={'requestPayment': None}) |
|
465 | 465 |
response = self.send_request(request) |
466 |
- payer = getTextFromXml(response['data'], "Payer") |
|
466 |
+ resp_data = response.get('data', '') |
|
467 |
+ if resp_data: |
|
468 |
+ payer = getTextFromXml(response['data'], "Payer") |
|
469 |
+ else: |
|
470 |
+ payer = None |
|
467 | 471 |
return payer |
468 | 472 |
|
469 | 473 |
def bucket_info(self, uri): |
... | ... |
@@ -472,7 +476,7 @@ class S3(object): |
472 | 472 |
try: |
473 | 473 |
response['requester-pays'] = self.get_bucket_requester_pays(uri) |
474 | 474 |
except S3Error as e: |
475 |
- response['requester-pays'] = 'none' |
|
475 |
+ response['requester-pays'] = None |
|
476 | 476 |
return response |
477 | 477 |
|
478 | 478 |
def website_info(self, uri, bucket_location = None): |
... | ... |
@@ -970,8 +970,10 @@ def cmd_info(args): |
970 | 970 |
else: |
971 | 971 |
info = s3.bucket_info(uri) |
972 | 972 |
output(u"%s (bucket):" % uri.uri()) |
973 |
- output(u" Location: %s" % info['bucket-location']) |
|
974 |
- output(u" Payer: %s" % info['requester-pays']) |
|
973 |
+ output(u" Location: %s" % (info['bucket-location'] |
|
974 |
+ or 'none')) |
|
975 |
+ output(u" Payer: %s" % (info['requester-pays'] |
|
976 |
+ or 'none')) |
|
975 | 977 |
expiration = s3.expiration_info(uri, cfg.bucket_location) |
976 | 978 |
if expiration: |
977 | 979 |
expiration_desc = "Expiration Rule: " |