#NEWLINE# def remove_from_s3( self , file_name , bucket_name ) : #NEWLINE# #INDENT# "\n        Given a file name and a bucket, remove it from S3.\n\n        There's no reason to keep the file hosted on S3 once its been made into a Lambda function, so we can delete it from S3.\n\n        Returns True on success, False on failure.\n\n        " #NEWLINE# s3 = self . boto_session . resource ( 's3' ) #NEWLINE# bucket = s3 . Bucket ( bucket_name ) #NEWLINE# try : #NEWLINE# #INDENT# s3 . meta . client . head_bucket ( Bucket = bucket_name ) #NEWLINE# #UNINDENT# except botocore . exceptions . ClientError as e : #NEWLINE# #INDENT# error_code = int ( e . response [ 'Error' ] [ 'Code' ] ) #NEWLINE# if ( error_code == 404 ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# delete_keys = { #NEWLINE# #INDENT# 'Objects' : [ { #NEWLINE# #INDENT# 'Key' : file_name , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# response = bucket . delete_objects ( Delete = delete_keys ) #NEWLINE# if ( response [ 'ResponseMetadata' ] [ 'HTTPStatusCode' ] == 200 ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return False