#NEWLINE# def upload_s3( gallery , settings = None ) : #NEWLINE# #INDENT# upload_files = [ ] #NEWLINE# for ( root , dirs , files ) in os . walk ( gallery . settings [ 'destination' ] ) : #NEWLINE# #INDENT# for f in files : #NEWLINE# #INDENT# path = os . path . join ( root [ ( len ( gallery . settings [ 'destination' ] ) + 1 ) : ] , f ) #NEWLINE# size = os . path . getsize ( os . path . join ( root , f ) ) #NEWLINE# upload_files += [ ( upload_files , size ) ] #NEWLINE# #UNINDENT# #UNINDENT# conn = boto . connect_s3 ( ) #NEWLINE# bucket = conn . get_bucket ( gallery . settings [ 'upload_s3_options' ] [ 'bucket' ] ) #NEWLINE# with progressbar ( upload_files , label = 'Uploading files to S3' ) as progress_upload : #NEWLINE# #INDENT# for ( f , size ) in progress_upload : #NEWLINE# #INDENT# if ( gallery . settings [ 'upload_s3_options' ] [ 'overwrite' ] == False ) : #NEWLINE# #INDENT# key = bucket . get_key ( f ) #NEWLINE# if ( ( key != None ) and ( key . size == size ) ) : #NEWLINE# #INDENT# cache_metadata = generate_cache_metadata ( gallery , f ) #NEWLINE# if ( key . get_metadata ( 'Cache-Control' ) != cache_metadata ) : #NEWLINE# #INDENT# key . set_remote_metadata ( { #NEWLINE# #INDENT# 'Cache-Control' : cache_metadata , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , True ) #NEWLINE# #UNINDENT# logger . debug ( ( 'Skipping file %s' % f ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# upload_file ( gallery , bucket , f ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# upload_file ( gallery , bucket , f )