Merge "Fix error handling of reset method in s3_test_client.py"

This commit is contained in:
Jenkins
2015-03-24 01:56:56 +00:00
committed by Gerrit Code Review

View File

@@ -16,7 +16,6 @@
import os import os
from boto.s3.connection import S3Connection, OrdinaryCallingFormat, \ from boto.s3.connection import S3Connection, OrdinaryCallingFormat, \
BotoClientError, S3ResponseError BotoClientError, S3ResponseError
from swift3.response import NoSuchKey, NoSuchBucket
RETRY_COUNT = 3 RETRY_COUNT = 3
@@ -65,16 +64,16 @@ class Connection(object):
buckets = self.conn.get_all_buckets() buckets = self.conn.get_all_buckets()
if not buckets: if not buckets:
break break
for bucket in buckets: for bucket in buckets:
for obj in bucket.list():
try:
bucket.delete_key(obj.name)
except NoSuchKey:
pass
try: try:
for obj in bucket.list():
bucket.delete_key(obj.name)
self.conn.delete_bucket(bucket.name) self.conn.delete_bucket(bucket.name)
except NoSuchBucket: except S3ResponseError as e:
pass # 404 means NoSuchBucket or NoSuchKey
if e.status != 404:
raise
except (BotoClientError, S3ResponseError) as e: except (BotoClientError, S3ResponseError) as e:
exceptions.append(e) exceptions.append(e)
if exceptions: if exceptions: