def _set_status(m, comment=INVALID_RESPONSE, status=False, out=None):
 m['out'] = out
 m['status'] = status
 m['logs'] = LOG.messages[:]
 m['logs_by_level'] = LOG.by_level.copy()
 (outlog, outlog_by_level) = ('', '')
 m['comment'] = comment
 if (out and isinstance(out, string_types)):
  outlog += HR
  outlog += 'OUTPUT:\n'
  outlog += '{0}\n'.format(_encode_string(out))
  outlog += HR
 if m['logs']:
  outlog += HR
  outlog += 'Log summary:\n'
  outlog += HR
  outlog_by_level += HR
  outlog_by_level += 'Log summary by level:\n'
  outlog_by_level += HR
  for (level, msg) in m['logs']:
   outlog += '\n{0}: {1}\n'.format(level.upper(), _encode_string(msg))
  for logger in ('error', 'warn', 'info', 'debug'):
   logs = m['logs_by_level'].get(logger, [])
   if logs:
    outlog_by_level += '\n{0}:\n'.format(logger.upper())
    for (idx, log) in enumerate(logs[:]):
     logs[idx] = _encode_string(log)
    outlog_by_level += '\n'.join(logs)
    outlog_by_level += '\n'
  outlog += HR
 m['outlog'] = outlog
 m['outlog_by_level'] = outlog_by_level
 return _encode_status(m)

def _set_status ( m , comment = INVALID_RESPONSE , status = False , out = None ) : m [ 'out' ] = out m [ 'status' ] = status m [ 'logs' ] = LOG . messages [ : ] m [ 'logs_by_level' ] = LOG . by_level . copy ( ) ( outlog , outlog_by_level ) = ( '' , '' ) m [ 'comment' ] = comment if ( out and isinstance ( out , string_types ) ) : outlog += HR outlog += 'OUTPUT:\n' outlog += '{0}\n' . format ( _encode_string ( out ) ) outlog += HR if m [ 'logs' ] : outlog += HR outlog += 'Log summary:\n' outlog += HR outlog_by_level += HR outlog_by_level += 'Log summary by level:\n' outlog_by_level += HR for ( level , msg ) in m [ 'logs' ] : outlog += '\n{0}: {1}\n' . format ( level . upper ( ) , _encode_string ( msg ) ) for logger in ( 'error' , 'warn' , 'info' , 'debug' ) : logs = m [ 'logs_by_level' ] . get ( logger , [ ] ) if logs : outlog_by_level += '\n{0}:\n' . format ( logger . upper ( ) ) for ( idx , log ) in enumerate ( logs [ : ] ) : logs [ idx ] = _encode_string ( log ) outlog_by_level += '\n' . join ( logs ) outlog_by_level += '\n' outlog += HR m [ 'outlog' ] = outlog m [ 'outlog_by_level' ] = outlog_by_level return _encode_status ( m )
assign status data to a dict .