Fixing s3 failures when bucket names contain dots

This commit is contained in:
James Cammarata 2015-07-30 13:46:42 -04:00
parent c6da9d0758
commit 4c4e978360

View file

@ -438,6 +438,12 @@ def main():
if not s3_url and 'S3_URL' in os.environ: if not s3_url and 'S3_URL' in os.environ:
s3_url = os.environ['S3_URL'] s3_url = os.environ['S3_URL']
# bucket names with .'s in them need to use the calling_format option,
# otherwise the connection will fail. See https://github.com/boto/boto/issues/2836
# for more details.
if '.' in bucket:
aws_connect_kwargs['calling_format'] = OrdinaryCallingFormat()
# Look at s3_url and tweak connection settings # Look at s3_url and tweak connection settings
# if connecting to Walrus or fakes3 # if connecting to Walrus or fakes3
try: try:
@ -454,7 +460,7 @@ def main():
walrus = urlparse.urlparse(s3_url).hostname walrus = urlparse.urlparse(s3_url).hostname
s3 = boto.connect_walrus(walrus, **aws_connect_kwargs) s3 = boto.connect_walrus(walrus, **aws_connect_kwargs)
else: else:
s3 = boto.s3.connect_to_region(location, is_secure=True, calling_format=OrdinaryCallingFormat(), **aws_connect_kwargs) s3 = boto.s3.connect_to_region(location, is_secure=True, **aws_connect_kwargs)
# use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases # use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases
if s3 is None: if s3 is None:
s3 = boto.connect_s3(**aws_connect_kwargs) s3 = boto.connect_s3(**aws_connect_kwargs)