#NEWLINE# def __call__( self ) : #NEWLINE# #INDENT# LOGGER . debug ( 'Uploading part copy %s for filename: %s' , self . _part_number , self . _filename . src ) #NEWLINE# total_file_size = self . _filename . size #NEWLINE# start_range = ( ( self . _part_number - 1 ) * self . _chunk_size ) #NEWLINE# if self . _is_last_part ( self . _part_number ) : #NEWLINE# #INDENT# end_range = ( total_file_size - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# end_range = ( ( start_range + self . _chunk_size ) - 1 ) #NEWLINE# #UNINDENT# range_param = ( 'bytes=%s-%s' % ( start_range , end_range ) ) #NEWLINE# try : #NEWLINE# #INDENT# LOGGER . debug ( 'Waiting for upload id.' ) #NEWLINE# upload_id = self . _upload_context . wait_for_upload_id ( ) #NEWLINE# ( bucket , key ) = find_bucket_key ( self . _filename . dest ) #NEWLINE# ( src_bucket , src_key ) = find_bucket_key ( self . _filename . src ) #NEWLINE# params = { #NEWLINE# #INDENT# 'Bucket' : bucket , #NEWLINE# 'Key' : key , #NEWLINE# 'PartNumber' : self . _part_number , #NEWLINE# 'UploadId' : upload_id , #NEWLINE# 'CopySource' : { #NEWLINE# #INDENT# 'Bucket' : src_bucket , #NEWLINE# 'Key' : src_key , #NEWLINE# #UNINDENT# } , #NEWLINE# 'CopySourceRange' : range_param , #NEWLINE# #UNINDENT# } #NEWLINE# RequestParamsMapper . map_upload_part_copy_params ( params , self . _params ) #NEWLINE# response_data = self . _filename . client . upload_part_copy ( ** params ) #NEWLINE# etag = response_data [ 'CopyPartResult' ] [ 'ETag' ] [ 1 : ( - 1 ) ] #NEWLINE# self . _upload_context . announce_finished_part ( etag = etag , part_number = self . _part_number ) #NEWLINE# message = print_operation ( self . _filename , 0 ) #NEWLINE# result = { #NEWLINE# #INDENT# 'message' : message , #NEWLINE# 'total_parts' : self . _total_parts ( ) , #NEWLINE# 'error' : False , #NEWLINE# #UNINDENT# } #NEWLINE# self . _result_queue . put ( PrintTask ( ** result ) ) #NEWLINE# #UNINDENT# except UploadCancelledError as e : #NEWLINE# #INDENT# LOGGER . debug ( 'Not uploading part copy, task has been cancelled.' ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# LOGGER . debug ( 'Error during upload part copy: %s' , e , exc_info = True ) #NEWLINE# message = print_operation ( self . _filename , failed = True , dryrun = False ) #NEWLINE# message += ( '\n' + str ( e ) ) #NEWLINE# result = { #NEWLINE# #INDENT# 'message' : message , #NEWLINE# 'error' : True , #NEWLINE# #UNINDENT# } #NEWLINE# self . _result_queue . put ( PrintTask ( ** result ) ) #NEWLINE# self . _upload_context . cancel_upload ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOGGER . debug ( 'Copy part number %s completed for filename: %s' , self . _part_number , self . _filename . src )