Exemplo n.º 1
0
def check_response_errors(response, session):
    """
    Checks status of response response and throws appropriate error.
    """
    if response['status'] != 'ok':
        from wi.utils.auth import logout
        error_code = response['status']
        error_msg = get_error(error_code)

        raise RestErrorException(error_msg)

    return response
Exemplo n.º 2
0
def check_response_errors(response, session):
    """
    Checks status of response response and throws appropriate error.
    """
    if response['status'] != 'ok':
        from wi.utils.auth import logout
        error_code = response['status']
        error_msg = get_error(error_code)

        raise RestErrorException(error_msg)

    return response
Exemplo n.º 3
0
def _multiple_id_return(response, id_list, desc, success_msg):
    """
    Helper function creating ajax response with error codes.
    """
    all_ok = True
    for machine_response in response:
        if machine_response['status'] != 'ok':
            all_ok = False
    if all_ok:
        count = len(id_list)
        return messages_ajax.success(success_msg(desc, count))
    else:
        for i in range(len(response)):
            response[i]['type'] = 'vm'
            response[i]['vmid'] = id_list[i]
            response[i]['status_text'] = unicode(get_error(response[i]['status']))
        return messages_ajax.success(response, 7999)
Exemplo n.º 4
0
def _multiple_id_return(response, id_list, desc, success_msg):
    """
    Helper function creating ajax response with error codes.
    """
    all_ok = True
    for machine_response in response:
        if machine_response['status'] != 'ok':
            all_ok = False
    if all_ok:
        count = len(id_list)
        return messages_ajax.success(success_msg(desc, count))
    else:
        for i in range(len(response)):
            response[i]['type'] = 'vm'
            response[i]['vmid'] = id_list[i]
            response[i]['status_text'] = unicode(
                get_error(response[i]['status']))
        return messages_ajax.success(response, 7999)