From 34daa30e09dd39c19f5ba53e974f3f9f565001f4 Mon Sep 17 00:00:00 2001 From: Frank Boerman Date: Mon, 13 Sep 2021 23:31:15 +0200 Subject: [PATCH] fixed the check for no data returned due to new way ENTSO-E server handles it this fixes #129 --- entsoe/entsoe.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/entsoe/entsoe.py b/entsoe/entsoe.py index f763083..a6fa3b6 100644 --- a/entsoe/entsoe.py +++ b/entsoe/entsoe.py @@ -20,7 +20,7 @@ parse_netpositions, parse_procured_balancing_capacity __title__ = "entsoe-py" -__version__ = "0.3.8" +__version__ = "0.4" __author__ = "EnergieID.be" __license__ = "MIT" @@ -138,6 +138,13 @@ def _base_request(self, params: Dict, start: pd.Timestamp, f"documents and cannot be fulfilled as is.") raise e else: + # ENTSO-E has changed their server to also respond with 200 if there is no data but all parameters are valid + # this means we need to check the contents for this error even when status code 200 is returned + # to prevent parsing the full response do a text matching instead of full parsing + # also only do this when response type content is text and not for example a zip file + if response.headers.get('content-type', '') == 'application/xml': + if 'No matching data found' in response.text: + raise NoMatchingDataError return response @staticmethod