#NEWLINE# def handle( self , * args , **options ) : #NEWLINE# #INDENT# '\n        Sync files in the build directory to a specified S3 bucket\n        ' #NEWLINE# self . uploaded_files = 0 #NEWLINE# self . uploaded_file_list = [ ] #NEWLINE# self . deleted_files = 0 #NEWLINE# self . deleted_file_list = [ ] #NEWLINE# self . start_time = time . time ( ) #NEWLINE# self . set_options ( options ) #NEWLINE# if ( ( '.' in self . aws_bucket_name ) and ( sys . version_info [ : 3 ] >= ( 2 , 7 , 9 ) ) ) : #NEWLINE# #INDENT# self . conn = S3Connection ( settings . AWS_ACCESS_KEY_ID , settings . AWS_SECRET_ACCESS_KEY , calling_format = OrdinaryCallingFormat ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . conn = S3Connection ( settings . AWS_ACCESS_KEY_ID , settings . AWS_SECRET_ACCESS_KEY ) #NEWLINE# #UNINDENT# self . bucket = self . conn . get_bucket ( self . aws_bucket_name ) #NEWLINE# self . s3_key_dict = self . get_s3_key_dict ( ) #NEWLINE# self . local_file_list = self . get_local_file_list ( ) #NEWLINE# self . sync_with_s3 ( ) #NEWLINE# if ( ( not self . dry_run ) and ( not self . no_delete ) ) : #NEWLINE# #INDENT# self . deleted_file_list = list ( self . s3_key_dict . keys ( ) ) #NEWLINE# self . deleted_files = len ( self . deleted_file_list ) #NEWLINE# if self . deleted_files : #NEWLINE# #INDENT# logger . debug ( ( 'deleting %s keys' % self . deleted_files ) ) #NEWLINE# key_chunks = [ ] #NEWLINE# for i in range ( 0 , len ( self . deleted_file_list ) , 100 ) : #NEWLINE# #INDENT# key_chunks . append ( self . deleted_file_list [ i : ( i + 100 ) ] ) #NEWLINE# #UNINDENT# for chunk in key_chunks : #NEWLINE# #INDENT# self . bucket . delete_keys ( chunk ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not hasattr ( settings , 'BAKERY_VIEWS' ) ) : #NEWLINE# #INDENT# raise CommandError ( self . views_unconfig_msg ) #NEWLINE# #UNINDENT# for view_str in settings . BAKERY_VIEWS : #NEWLINE# #INDENT# view = get_callable ( view_str ) ( ) #NEWLINE# if hasattr ( view , 'post_publish' ) : #NEWLINE# #INDENT# getattr ( view , 'post_publish' ) ( self . bucket ) #NEWLINE# #UNINDENT# #UNINDENT# elapsed_time = ( time . time ( ) - self . start_time ) #NEWLINE# logger . info ( ( 'publish completed, %d uploaded and %d deleted files in %.2f seconds' % ( self . uploaded_files , self . deleted_files , elapsed_time ) ) ) #NEWLINE# if ( self . verbosity > 2 ) : #NEWLINE# #INDENT# for f in self . uploaded_file_list : #NEWLINE# #INDENT# logger . info ( ( 'updated file: %s' % f ) ) #NEWLINE# #UNINDENT# for f in self . deleted_file_list : #NEWLINE# #INDENT# logger . info ( ( 'deleted file: %s' % f ) ) #NEWLINE# #UNINDENT# #UNINDENT# if self . dry_run : #NEWLINE# #INDENT# logger . info ( 'publish executed with the --dry-run option. No content was changed on S3.' )