#NEWLINE# def display_output( data , out = None , opts = None ) : #NEWLINE# #INDENT# '\n    Print the passed data using the desired output\n    ' #NEWLINE# if ( ofh is None ) : #NEWLINE# #INDENT# opts = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# display_data = try_printout ( data , out , opts ) #NEWLINE# output_filename = opts . get ( 'output_file' , None ) #NEWLINE# log . trace ( 'data = {0}' . format ( data ) ) #NEWLINE# try : #NEWLINE# #INDENT# if output_filename : #NEWLINE# #INDENT# with salt . utils . fopen ( output_filename , 'a' ) as ofh : #NEWLINE# #INDENT# fdata = display_data #NEWLINE# if isinstance ( fdata , six . text_type ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# fdata = fdata . encode ( 'utf-8' ) #NEWLINE# #UNINDENT# except ( UnicodeDecodeError , UnicodeEncodeError ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# ofh . write ( fdata ) #NEWLINE# ofh . write ( '\n' ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# if display_data : #NEWLINE# #INDENT# print_cli ( display_data ) #NEWLINE# #UNINDENT# #UNINDENT# except IOError as exc : #NEWLINE# #INDENT# if ( exc . errno != errno . EPIPE ) : #NEWLINE# #INDENT# raise exc