def _check_gle_response(response):
 response = _unpack_response(response)
 assert (response['number_returned'] == 1)
 result = response['data'][0]
 _check_command_response(result)
 if result.get('wtimeout', False):
  raise WTimeoutError(result.get('errmsg', result.get('err')), result.get('code'), result)
 error_msg = result.get('err', '')
 if (error_msg is None):
  return result
 if error_msg.startswith('not master'):
  raise NotMasterError(error_msg, result)
 details = result
 if ('errObjects' in result):
  for errobj in result['errObjects']:
   if (errobj.get('err') == error_msg):
    details = errobj
    break
 code = details.get('code')
 if (code in (11000, 11001, 12582)):
  raise DuplicateKeyError(details['err'], code, result)
 raise OperationFailure(details['err'], code, result)

def _check_gle_response ( response ) : response = _unpack_response ( response ) assert ( response [ 'number_returned' ] == 1 ) result = response [ 'data' ] [ 0 ] _check_command_response ( result ) if result . get ( 'wtimeout' , False ) : raise WTimeoutError ( result . get ( 'errmsg' , result . get ( 'err' ) ) , result . get ( 'code' ) , result ) error_msg = result . get ( 'err' , '' ) if ( error_msg is None ) : return result if error_msg . startswith ( 'not master' ) : raise NotMasterError ( error_msg , result ) details = result if ( 'errObjects' in result ) : for errobj in result [ 'errObjects' ] : if ( errobj . get ( 'err' ) == error_msg ) : details = errobj break code = details . get ( 'code' ) if ( code in ( 11000 , 11001 , 12582 ) ) : raise DuplicateKeyError ( details [ 'err' ] , code , result ) raise OperationFailure ( details [ 'err' ] , code , result )
return getlasterror response as a dict .