Skip to content

Commit 34daa30

Browse files
committed
fixed the check for no data returned due to new way ENTSO-E server handles it
this fixes #129
1 parent 745f226 commit 34daa30

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

entsoe/entsoe.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
parse_netpositions, parse_procured_balancing_capacity
2121

2222
__title__ = "entsoe-py"
23-
__version__ = "0.3.8"
23+
__version__ = "0.4"
2424
__author__ = "EnergieID.be"
2525
__license__ = "MIT"
2626

@@ -138,6 +138,13 @@ def _base_request(self, params: Dict, start: pd.Timestamp,
138138
f"documents and cannot be fulfilled as is.")
139139
raise e
140140
else:
141+
# ENTSO-E has changed their server to also respond with 200 if there is no data but all parameters are valid
142+
# this means we need to check the contents for this error even when status code 200 is returned
143+
# to prevent parsing the full response do a text matching instead of full parsing
144+
# also only do this when response type content is text and not for example a zip file
145+
if response.headers.get('content-type', '') == 'application/xml':
146+
if 'No matching data found' in response.text:
147+
raise NoMatchingDataError
141148
return response
142149

143150
@staticmethod

0 commit comments

Comments
 (0)