#NEWLINE# def _upload_small_file( self , upload_source , file_name , content_type , file_info , progress_listener ) : #NEWLINE# #INDENT# content_length = upload_source . get_content_length ( ) #NEWLINE# sha1_sum = upload_source . get_content_sha1 ( ) #NEWLINE# exception_info_list = [ ] #NEWLINE# for _ in six . moves . xrange ( self . MAX_UPLOAD_ATTEMPTS ) : #NEWLINE# #INDENT# ( upload_url , upload_auth_token ) = self . _get_upload_data ( ) #NEWLINE# try : #NEWLINE# #INDENT# with upload_source . open ( ) as file : #NEWLINE# #INDENT# progress_listener . set_total_bytes ( content_length ) #NEWLINE# input_stream = StreamWithProgress ( file , progress_listener ) #NEWLINE# upload_response = self . api . raw_api . upload_file ( upload_url , upload_auth_token , file_name , content_length , content_type , sha1_sum , file_info , input_stream ) #NEWLINE# self . api . account_info . put_bucket_upload_url ( self . id_ , upload_url , upload_auth_token ) #NEWLINE# return FileVersionInfoFactory . from_api_response ( upload_response ) #NEWLINE# #UNINDENT# #UNINDENT# except B2Error as e : #NEWLINE# #INDENT# if ( not e . should_retry_upload ( ) ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# exception_info_list . append ( e ) #NEWLINE# self . api . account_info . clear_bucket_upload_data ( self . id_ ) #NEWLINE# #UNINDENT# #UNINDENT# raise MaxRetriesExceeded ( self . MAX_UPLOAD_ATTEMPTS , exception_info_list )