#NEWLINE# def bucket_exists( access_key , secret_key , bucket_name ) : #NEWLINE# #INDENT# 'Tests for the existance of a bucket and if the user\n    can access it with the given keys\n    ' #NEWLINE# if ( not bucket_name ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# connection = connect_s3 ( access_key , secret_key ) #NEWLINE# if ( bucket_name != bucket_name . lower ( ) ) : #NEWLINE# #INDENT# connection . calling_format = OrdinaryCallingFormat ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# connect_s3 ( access_key , secret_key ) . head_bucket ( bucket_name ) #NEWLINE# #UNINDENT# except exception . S3ResponseError as e : #NEWLINE# #INDENT# if ( e . status not in ( 301 , 302 ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# return True