def display_output(data, out=None, opts=None, **kwargs):
 if (opts is None):
  opts = {}
 display_data = try_printout(data, out, opts, **kwargs)
 output_filename = opts.get('output_file', None)
 log.trace('data = {0}'.format(data))
 try:
  if output_filename:
   if (not hasattr(output_filename, 'write')):
    ofh = salt.utils.fopen(output_filename, 'a')
    fh_opened = True
   else:
    ofh = output_filename
    fh_opened = False
   try:
    fdata = display_data
    if isinstance(fdata, six.text_type):
     try:
      fdata = fdata.encode('utf-8')
     except (UnicodeDecodeError, UnicodeEncodeError):
      pass
    if fdata:
     if six.PY3:
      ofh.write(fdata.decode())
     else:
      ofh.write(fdata)
     ofh.write('\n')
   finally:
    if fh_opened:
     ofh.close()
   return
  if display_data:
   print_cli(display_data)
 except IOError as exc:
  if (exc.errno != errno.EPIPE):
   raise exc

def display_output ( data , out = None , opts = None , ** kwargs ) : if ( opts is None ) : opts = { } display_data = try_printout ( data , out , opts , ** kwargs ) output_filename = opts . get ( 'output_file' , None ) log . trace ( 'data = {0}' . format ( data ) ) try : if output_filename : if ( not hasattr ( output_filename , 'write' ) ) : ofh = salt . utils . fopen ( output_filename , 'a' ) fh_opened = True else : ofh = output_filename fh_opened = False try : fdata = display_data if isinstance ( fdata , six . text_type ) : try : fdata = fdata . encode ( 'utf-8' ) except ( UnicodeDecodeError , UnicodeEncodeError ) : pass if fdata : if six . PY3 : ofh . write ( fdata . decode ( ) ) else : ofh . write ( fdata ) ofh . write ( '\n' ) finally : if fh_opened : ofh . close ( ) return if display_data : print_cli ( display_data ) except IOError as exc : if ( exc . errno != errno . EPIPE ) : raise exc
print the passed data using the desired output .