#NEWLINE# def _download_part( self ) : #NEWLINE# #INDENT# total_file_size = self . _filename . size #NEWLINE# start_range = ( self . _part_number * self . _chunk_size ) #NEWLINE# if ( self . _part_number == ( int ( ( total_file_size / self . _chunk_size ) ) - 1 ) ) : #NEWLINE# #INDENT# end_range = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# end_range = ( ( start_range + self . _chunk_size ) - 1 ) #NEWLINE# #UNINDENT# range_param = ( 'bytes=%s-%s' % ( start_range , e ) ) #NEWLINE# LOGGER . debug ( 'Downloading bytes range of %s for file %s' , range_param , self . _filename . dest ) #NEWLINE# ( bucket , key ) = find_bucket_key ( self . _filename . src ) #NEWLINE# params = { #NEWLINE# #INDENT# 'Bucket' : bucket , #NEWLINE# 'Key' : key , #NEWLINE# 'Range' : range_param , #NEWLINE# #UNINDENT# } #NEWLINE# RequestParamsMapper . map_get_object_params ( params , self . _params ) #NEWLINE# for i in range ( self . TOTAL_ATTEMPTS ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# LOGGER . debug ( 'Making GetObject requests with byte range: %s' , range_param ) #NEWLINE# response_data = self . _client . get_object ( ** params ) #NEWLINE# LOGGER . debug ( 'Response received from GetObject' ) #NEWLINE# body = response_data [ 'Body' ] #NEWLINE# self . _queue_writes ( body ) #NEWLINE# self . _context . announce_completed_part ( self . _part_number ) #NEWLINE# message = print_operation ( self . _filename , 0 ) #NEWLINE# total_parts = int ( ( self . _filename . size / self . _chunk_size ) ) #NEWLINE# result = { #NEWLINE# #INDENT# 'message' : message , #NEWLINE# 'error' : False , #NEWLINE# 'total_parts' : total_parts , #NEWLINE# #UNINDENT# } #NEWLINE# self . _result_queue . put ( PrintTask ( ** result ) ) #NEWLINE# LOGGER . debug ( 'Task complete: %s' , self ) #NEWLINE# return #NEWLINE# #UNINDENT# except ( socket . timeout , socket . error , ReadTimeoutError ) as e : #NEWLINE# #INDENT# LOGGER . debug ( 'Timeout error caught, retrying request, (attempt %s / %s)' , i , self . TOTAL_ATTEMPTS , exc_info = True ) #NEWLINE# continue #NEWLINE# #UNINDENT# except IncompleteReadError as e : #NEWLINE# #INDENT# LOGGER . debug ( 'Incomplete read detected: %s, (attempt %s / %s)' , e , i , self . TOTAL_ATTEMPTS ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# raise RetriesExeededError ( ( 'Maximum number of attempts exceeded: %s' % self . TOTAL_ATTEMPTS ) )