#NEWLINE# def create_or_update_file( file_stream , file_name , self_id , parent_path , parent_id ) : #NEWLINE# #INDENT# path = '/' #NEWLINE# if ( parent_path is not None ) : #NEWLINE# #INDENT# path = ( ( '/' + parent_id ) + '/' ) #NEWLINE# #UNINDENT# if ( self_id is None ) : #NEWLINE# #INDENT# name = file_name #NEWLINE# create = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# name = self_id #NEWLINE# create = False #NEWLINE# path = '/' #NEWLINE# #UNINDENT# node = models . Node . load ( settings . TABULATE_LOGS_NODE_ID ) #NEWLINE# user = models . User . load ( settings . TABULATE_LOGS_USER_ID ) #NEWLINE# retry = 0 #NEWLINE# while ( retry < 3 ) : #NEWLINE# #INDENT# resp = utils . send_file ( name , 'file-upload' , file_stream , node , user , create , path ) #NEWLINE# sleep ( 1 ) #NEWLINE# if ( resp . status_code != 503 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# retry += 1 #NEWLINE# #UNINDENT# if ( retry == 3 ) : #NEWLINE# #INDENT# logger . debug ( 'response = {}' . format ( resp . json ( ) ) ) #NEWLINE# resp . raise_for_status ( )