How to use the meteomatics.exceptions.WeatherApiException function in meteomatics

To help you get started, we’ve selected a few meteomatics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github meteomatics / python-connector-api / meteomatics / exceptions.py View on Github external
pass


class PaymentRequired(WeatherApiException):
    pass


class Forbidden(WeatherApiException):
    pass


class NotFound(WeatherApiException):
    pass


class RequestTimeout(WeatherApiException):
    pass


class PayloadTooLarge(WeatherApiException):
    pass


class UriTooLong(WeatherApiException):
    pass


class TooManyRequests(WeatherApiException):
    pass


class InternalServerError(WeatherApiException):
github meteomatics / python-connector-api / meteomatics / exceptions.py View on Github external
pass


class RequestTimeout(WeatherApiException):
    pass


class PayloadTooLarge(WeatherApiException):
    pass


class UriTooLong(WeatherApiException):
    pass


class TooManyRequests(WeatherApiException):
    pass


class InternalServerError(WeatherApiException):
    pass

_exceptions = {400: BadRequest,
               401: Unauthorized,
               403: Forbidden,
               404: NotFound,
               408: RequestTimeout,
               413: PayloadTooLarge,
               414: UriTooLong,
               429: TooManyRequests,
               500: InternalServerError}
github meteomatics / python-connector-api / meteomatics / api.py View on Github external
version = binary_reader.get_int()
    precision = binary_reader.get_int()
    num_payloads_per_forecast = binary_reader.get_int()
    payload_meta = binary_reader.get_int()
    num_forecasts = binary_reader.get_int()
    forecast_dates_ux = [binary_reader.get_unsigned_long() for _ in range(num_forecasts)]

    # precision in bytes
    DOUBLE = 8
    FLOAT = 4

    if version != 2:
        raise WeatherApiException("Only MBG version 2 supported, this is version {}".format(version))

    if precision not in [FLOAT, DOUBLE]:
        raise WeatherApiException("Received wrong precision {}".format(precision))

    if num_payloads_per_forecast > 100000:
        raise WeatherApiException("numForecasts too big (possibly big-endian): {}".format(num_payloads_per_forecast))

    if num_payloads_per_forecast != 1:
        raise WeatherApiException(
            "Wrong number of payloads per forecast date received: {}".format(num_payloads_per_forecast))

    if payload_meta != 0:
        raise WeatherApiException("Wrong payload type received: {}".format(payload_meta))

    lons = []
    lats = []

    value_data_type = "float" if precision == FLOAT else "double"
    num_lat = binary_reader.get_int()
github meteomatics / python-connector-api / meteomatics / exceptions.py View on Github external
# -*- coding: utf-8 -*-

from collections import defaultdict


class WeatherApiException(Exception):
    def __init__(self, message):
        super(WeatherApiException, self).__init__(message)


class BadRequest(WeatherApiException):
    pass


class Unauthorized(WeatherApiException):
    pass


class PaymentRequired(WeatherApiException):
    pass


class Forbidden(WeatherApiException):
    pass


class NotFound(WeatherApiException):
    pass


class RequestTimeout(WeatherApiException):
github meteomatics / python-connector-api / meteomatics / exceptions.py View on Github external
pass


class Forbidden(WeatherApiException):
    pass


class NotFound(WeatherApiException):
    pass


class RequestTimeout(WeatherApiException):
    pass


class PayloadTooLarge(WeatherApiException):
    pass


class UriTooLong(WeatherApiException):
    pass


class TooManyRequests(WeatherApiException):
    pass


class InternalServerError(WeatherApiException):
    pass

_exceptions = {400: BadRequest,
               401: Unauthorized,
github meteomatics / python-connector-api / meteomatics / exceptions.py View on Github external
API_EXCEPTIONS = defaultdict(lambda: WeatherApiException, _exceptions)
github meteomatics / python-connector-api / meteomatics / exceptions.py View on Github external
# -*- coding: utf-8 -*-

from collections import defaultdict


class WeatherApiException(Exception):
    def __init__(self, message):
        super(WeatherApiException, self).__init__(message)


class BadRequest(WeatherApiException):
    pass


class Unauthorized(WeatherApiException):
    pass


class PaymentRequired(WeatherApiException):
    pass


class Forbidden(WeatherApiException):
    pass


class NotFound(WeatherApiException):
github meteomatics / python-connector-api / meteomatics / api.py View on Github external
# precision in bytes
    DOUBLE = 8
    FLOAT = 4

    if version != 2:
        raise WeatherApiException("Only MBG version 2 supported, this is version {}".format(version))

    if precision not in [FLOAT, DOUBLE]:
        raise WeatherApiException("Received wrong precision {}".format(precision))

    if num_payloads_per_forecast > 100000:
        raise WeatherApiException("numForecasts too big (possibly big-endian): {}".format(num_payloads_per_forecast))

    if num_payloads_per_forecast != 1:
        raise WeatherApiException(
            "Wrong number of payloads per forecast date received: {}".format(num_payloads_per_forecast))

    if payload_meta != 0:
        raise WeatherApiException("Wrong payload type received: {}".format(payload_meta))

    lons = []
    lats = []

    value_data_type = "float" if precision == FLOAT else "double"
    num_lat = binary_reader.get_int()

    for _ in range(num_lat):
        lats.append(binary_reader.get_double())

    num_lon = binary_reader.get_int()
    for _ in range(num_lon):
github meteomatics / python-connector-api / meteomatics / exceptions.py View on Github external
pass


class NotFound(WeatherApiException):
    pass


class RequestTimeout(WeatherApiException):
    pass


class PayloadTooLarge(WeatherApiException):
    pass


class UriTooLong(WeatherApiException):
    pass


class TooManyRequests(WeatherApiException):
    pass


class InternalServerError(WeatherApiException):
    pass

_exceptions = {400: BadRequest,
               401: Unauthorized,
               403: Forbidden,
               404: NotFound,
               408: RequestTimeout,
               413: PayloadTooLarge,