#NEWLINE# def get_bucket( self , bucket_name ) : #NEWLINE# #INDENT# 'Get the bucket, connecting through the appropriate endpoint.' #NEWLINE# s3_conn = self . make_s3_conn ( ) #NEWLINE# bucket = s3_conn . get_bucket ( bucket_name ) #NEWLINE# if self . _s3_endpoint : #NEWLINE# #INDENT# return bucket #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# location = bucket . get_location ( ) #NEWLINE# #UNINDENT# except boto . exception . S3ResponseError as e : #NEWLINE# #INDENT# if ( e . status == 403 ) : #NEWLINE# #INDENT# log . warning ( 'Could not infer endpoint for bucket %s; assuming %s' , bucket_name , s3_conn . host ) #NEWLINE# return bucket #NEWLINE# #UNINDENT# raise #NEWLINE# #UNINDENT# if ( s3_endpoint_for_region ( location ) != s3_conn . host ) : #NEWLINE# #INDENT# s3_conn = self . make_s3_conn ( location ) #NEWLINE# bucket = s3_conn . get_bucket ( bucket_name ) #NEWLINE# #UNINDENT# return bucket