#NEWLINE# def _push( self , args ) : #NEWLINE# #INDENT# self . dog . timeout = args . timeout #NEWLINE# for f in args . file : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# dash_obj = json . load ( f ) #NEWLINE# #UNINDENT# except Exception as err : #NEWLINE# #INDENT# raise Exception ( 'Could not parse {0}: {1}' . format ( f . name , err ) ) #NEWLINE# #UNINDENT# dash_obj [ 'id' ] = int ( dash_obj [ 'id' ] ) #NEWLINE# if args . append_auto_text : #NEWLINE# #INDENT# datetime_str = datetime . now ( ) . strftime ( '%x %X' ) #NEWLINE# auto_text = '<br/>\nUpdated at {0} from {1} ({2}) on {3}' . format ( datetime_str , f . name , dash_obj [ 'id' ] , platform . node ( ) ) #NEWLINE# dash_obj [ 'description' ] += auto_text #NEWLINE# #UNINDENT# tpl_vars = dash_obj . get ( 'template_variables' , [ ] ) #NEWLINE# res = self . dog . update_dashboard ( dash_obj [ 'id' ] , dash_obj [ 'title' ] , dash_obj [ 'description' ] , dash_obj [ 'graphs' ] , template_variables = tpl_vars ) #NEWLINE# print ( tpl_vars ) #NEWLINE# if ( 'errors' in res ) : #NEWLINE# #INDENT# print_err ( 'Upload of dashboard {0} from file {1} failed.' . format ( dash_obj [ 'id' ] , f . name ) ) #NEWLINE# #UNINDENT# report_warnings ( res ) #NEWLINE# report_errors ( res ) #NEWLINE# if ( args . format == 'pretty' ) : #NEWLINE# #INDENT# print ( 'Uploaded file {0} (dashboard {1})' . format ( f . name , dash_obj [ 'id' ] ) )