Skip to content

Commit

Permalink
fixed the check for no data returned due to new way ENTSO-E server ha…
Browse files Browse the repository at this point in the history
…ndles it

this fixes #129
  • Loading branch information
fboerman committed Sep 13, 2021
1 parent 745f226 commit 34daa30
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion entsoe/entsoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 34daa30

Please sign in to comment.