s3cmd
s3cmd copied to clipboard
Suggestion: List buckets
There is hard dependency in next function from field CreationDate
def subcmd_all_buckets_list(s3):
response = s3.list_all_buckets()
for bucket in sorted(response["list"], key=lambda b:b["Name"]):
output(u"%s s3://%s" % (formatDateTime(bucket["CreationDate"]), <----------
bucket["Name"]))
By the docs, field is not required https://docs.aws.amazon.com/AmazonS3/latest/API/API_Bucket.html
I had problem with such field with NOT AWS S3 (my custom server).
Also, I believe, there is no reason for such hard dependency.
Suggestion:
def subcmd_all_buckets_list(s3):
response = s3.list_all_buckets()
for bucket in sorted(response["list"], key=lambda b:b["Name"]):
output(
u"%s s3://%s" % (
formatDateTime(
bucket.get("CreationDate", "<default value>"), <----------
),
bucket["Name"],
),
)