def process_errors(response):
 errors = []
 try:
  packets = defaultdict(dict)
  for (key, value) in response.headers.items():
   if (not key.lower().startswith('firelogger-')):
    continue
   (prefix, id_, seq) = key.split('-', 3)
   packets[id_][seq] = value
  msgs = []
  for contents in packets.values():
   keys = sorted(contents.keys(), key=int)
   encoded = '\n'.join((contents[key] for key in keys))
   decoded_json = base64.decodestring(encoded)
   packet = json.loads(decoded_json)
   msgs.extend(packet['logs'])
  if len(msgs):
   errors = msgs
 except Exception as exc:
  errors = [{'level': 'error', 'message': ('Problem parsing errors: %s' % exc), 'args': ['ParsingError']}]
 return errors

def process_errors ( response ) : errors = [ ] try : packets = defaultdict ( dict ) for ( key , value ) in response . headers . items ( ) : if ( not key . lower ( ) . startswith ( 'firelogger-' ) ) : continue ( prefix , id_ , seq ) = key . split ( '-' , 3 ) packets [ id_ ] [ seq ] = value msgs = [ ] for contents in packets . values ( ) : keys = sorted ( contents . keys ( ) , key = int ) encoded = '\n' . join ( ( contents [ key ] for key in keys ) ) decoded_json = base64 . decodestring ( encoded ) packet = json . loads ( decoded_json ) msgs . extend ( packet [ 'logs' ] ) if len ( msgs ) : errors = msgs except Exception as exc : errors = [ { 'level' : 'error' , 'message' : ( 'Problem parsing errors: %s' % exc ) , 'args' : [ 'ParsingError' ] } ] return errors
attempt to decode any firelogger-style error messages in the response from kumascript .