Exemple #1
0
def validate_form(form_xml):
    try:
        response = requests.post(
            get_nimbus_url() + const.ENDPOINT_VALIDATE_FORM,
            data=form_xml,
            headers={'Content-Type': 'application/xml'}
        )
    except RequestException as e:
        notify_exception(None, "Error calling Nimbus form validation endpoint")
        raise NimbusAPIException(e)

    try:
        response.raise_for_status()
    except HTTPError:
        notify_exception(None, "Error calling Nimbus form validation endpoint", details={
            'status_code': response.status_code
        })
        raise NimbusRequestException(response.status_code)

    api_result = ValidationAPIResult(response.json())
    result = FormValidationResult(
        problems=[problem.to_json() for problem in api_result.problems],
        success=api_result.validated,
        fatal_error=api_result.fatal_error,
    )
    return result
def validate_form(form_xml):
    try:
        response = requests.post(get_nimbus_url() +
                                 const.ENDPOINT_VALIDATE_FORM,
                                 data=form_xml,
                                 headers={'Content-Type': 'application/xml'},
                                 verify=False)
    except RequestException as e:
        notify_exception(None, "Error calling Nimbus form validation endpoint")
        raise NimbusAPIException(e)

    try:
        response.raise_for_status()
    except HTTPError:
        notify_exception(None,
                         "Error calling Nimbus form validation endpoint",
                         details={'status_code': response.status_code})
        raise NimbusRequestException(response.status_code)

    api_result = ValidationAPIResult(response.json())
    result = FormValidationResult(
        problems=[problem.to_json() for problem in api_result.problems],
        success=api_result.validated,
        fatal_error=api_result.fatal_error,
    )
    return result
def check_formplayer():
    try:
        res = requests.get('{}/serverup'.format(get_nimbus_url()), timeout=5)
    except requests.exceptions.ConnectTimeout:
        return ServiceStatus(False, "Could not establish a connection in time")
    except requests.ConnectionError:
        return ServiceStatus(False, "Could not connect to formplayer")
    else:
        msg = "Formplayer returned a {} status code".format(res.status_code)
        return ServiceStatus(res.ok, msg)
Exemple #4
0
def check_formplayer():
    try:
        res = requests.get("{}/serverup".format(get_nimbus_url()), timeout=5)
    except requests.exceptions.ConnectTimeout:
        return ServiceStatus(False, "Could not establish a connection in time")
    except requests.ConnectionError:
        return ServiceStatus(False, "Could not connect to formplayer")
    else:
        msg = "Formplayer returned a {} status code".format(res.status_code)
        return ServiceStatus(res.ok, msg)