Created
March 28, 2011 22:50
-
-
Save kwloafman/891480 to your computer and use it in GitHub Desktop.
diff for botobackend.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== modified file 'duplicity/backends/botobackend.py' | |
--- duplicity/backends/botobackend.py 2010-11-20 16:19:04 +0000 | |
+++ duplicity/backends/botobackend.py 2011-03-28 22:03:58 +0000 | |
@@ -157,6 +157,12 @@ | |
self.bucket = self.conn.lookup(self.bucket_name) | |
def put(self, source_path, remote_filename=None): | |
+ from boto.s3.connection import S3ResponseError | |
+ if globals.s3_european_buckets: | |
+ if not globals.s3_use_new_style: | |
+ log.FatalError("European bucket creation was requested, but not new-style " | |
+ "bucket addressing (--s3-use-new-style)", | |
+ log.ErrorCode.s3_bucket_not_style) | |
#Network glitch may prevent first few attempts of creating/looking up a bucket | |
for n in range(1, globals.num_retries+1): | |
if self.bucket: | |
@@ -164,15 +170,16 @@ | |
if n > 1: | |
time.sleep(30) | |
try: | |
- if globals.s3_european_buckets: | |
- if not globals.s3_use_new_style: | |
- log.FatalError("European bucket creation was requested, but not new-style " | |
- "bucket addressing (--s3-use-new-style)", | |
- log.ErrorCode.s3_bucket_not_style) | |
- from boto.s3.connection import Location #@UnresolvedImport | |
- self.bucket = self.conn.create_bucket(self.bucket_name, location = Location.EU) | |
- else: | |
- self.bucket = self.conn.create_bucket(self.bucket_name) | |
+ try: | |
+ self.bucket = self.conn.get_bucket(self.bucket_name, validate=True) | |
+ except S3ResponseError, e: | |
+ if e.code == "NoSuchBucket": | |
+ if globals.s3_european_buckets: | |
+ self.bucket = self.conn.create_bucket(self.bucket_name, location='EU') | |
+ else: | |
+ self.bucket = self.conn.create_bucket(self.bucket_name) | |
+ else: | |
+ raise e | |
except Exception, e: | |
log.Warn("Failed to create bucket (attempt #%d) '%s' failed (reason: %s: %s)" | |
"" % (n, self.bucket_name, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment