Fix error handling of reset method in s3_test_client.py

This patch fix error handling of reset method in s3_test_client.py.

Exceptions that occurred in reset method are S3ResponseError.
So, error handling is done according to the status of
S3ResponseError.

Change-Id: I6718f0c492213912052f40a4c6ed194ecf0b1fd0
This commit is contained in:
Naoto Nishizono
2015-03-19 16:06:15 +09:00
parent 00f759cb45
commit 3415b2e52b

View File

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