simple-dwd-weatherforecast 3.0.3__py3-none-any.whl → 3.0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simple_dwd_weatherforecast/dwdforecast.py +3 -3
- simple_dwd_weatherforecast/dwdmap.py +38 -17
- {simple_dwd_weatherforecast-3.0.3.dist-info → simple_dwd_weatherforecast-3.0.5.dist-info}/METADATA +1 -1
- {simple_dwd_weatherforecast-3.0.3.dist-info → simple_dwd_weatherforecast-3.0.5.dist-info}/RECORD +7 -7
- {simple_dwd_weatherforecast-3.0.3.dist-info → simple_dwd_weatherforecast-3.0.5.dist-info}/WHEEL +1 -1
- {simple_dwd_weatherforecast-3.0.3.dist-info → simple_dwd_weatherforecast-3.0.5.dist-info}/licenses/LICENCE +0 -0
- {simple_dwd_weatherforecast-3.0.3.dist-info → simple_dwd_weatherforecast-3.0.5.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
import csv
|
2
2
|
import importlib
|
3
|
+
import importlib.resources
|
3
4
|
import json
|
4
5
|
import math
|
5
6
|
from collections import OrderedDict, defaultdict
|
@@ -421,8 +422,7 @@ class Weather:
|
|
421
422
|
|
422
423
|
def get_reported_weather(self, weatherDataType: WeatherDataType, shouldUpdate=True):
|
423
424
|
if not self.has_measurement(self.station_id):
|
424
|
-
|
425
|
-
return None
|
425
|
+
raise ValueError("No report for this station available")
|
426
426
|
if shouldUpdate:
|
427
427
|
self.update(with_measurements=True)
|
428
428
|
if self.report_data is not None:
|
@@ -901,7 +901,7 @@ class Weather:
|
|
901
901
|
}
|
902
902
|
|
903
903
|
def get_weather_report(self, shouldUpdate=False):
|
904
|
-
if
|
904
|
+
if shouldUpdate and self.region is not None:
|
905
905
|
self.update(with_report=True)
|
906
906
|
return self.weather_report
|
907
907
|
|
@@ -260,15 +260,7 @@ class ImageLoop:
|
|
260
260
|
now = get_time_last_5_min(datetime.now(timezone.utc))
|
261
261
|
self._last_update = now - timedelta(minutes=5) * self._steps
|
262
262
|
|
263
|
-
|
264
|
-
self._last_update += timedelta(minutes=5)
|
265
|
-
# Lightning in the NCEW_EU layer is only available in the last 5 minutes
|
266
|
-
self._images.append(
|
267
|
-
self._get_image(
|
268
|
-
self._last_update,
|
269
|
-
with_lightning=(now - self._last_update) < timedelta(minutes=5),
|
270
|
-
)
|
271
|
-
)
|
263
|
+
self._load_images(now)
|
272
264
|
|
273
265
|
def update(self):
|
274
266
|
now = get_time_last_5_min(datetime.now(timezone.utc))
|
@@ -278,11 +270,38 @@ class ImageLoop:
|
|
278
270
|
self._full_reload()
|
279
271
|
# Update the buffer and fetch only the new images
|
280
272
|
else:
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
273
|
+
self._load_images(now)
|
274
|
+
|
275
|
+
def _load_images(self, now):
|
276
|
+
while now > self._last_update:
|
277
|
+
self._last_update += timedelta(minutes=5)
|
278
|
+
# Lightning in the NCEW_EU layer is only available in the last 5 minutes
|
279
|
+
try:
|
280
|
+
image = self._get_image(
|
281
|
+
self._last_update,
|
282
|
+
with_lightning=(now - self._last_update) < timedelta(minutes=5),
|
283
|
+
)
|
284
|
+
except ConnectionError as e:
|
285
|
+
raise ConnectionAbortedError(
|
286
|
+
f"Connection to DWD map servers failed: {e}"
|
285
287
|
)
|
288
|
+
except RuntimeError as e:
|
289
|
+
raise RuntimeError(f"Error: {e}") from e
|
290
|
+
except TypeError:
|
291
|
+
try:
|
292
|
+
image = self._get_image(
|
293
|
+
self._last_update,
|
294
|
+
with_lightning=False,
|
295
|
+
)
|
296
|
+
except ConnectionError as e:
|
297
|
+
raise ConnectionAbortedError(
|
298
|
+
f"Connection to DWD map servers failed: {e}"
|
299
|
+
)
|
300
|
+
except TypeError as e:
|
301
|
+
raise TypeError(
|
302
|
+
f"Unexpected content type: {e}. Please check the DWD map servers."
|
303
|
+
) from e
|
304
|
+
self._images.append(image)
|
286
305
|
|
287
306
|
def _get_image(
|
288
307
|
self,
|
@@ -325,14 +344,16 @@ class ImageLoop:
|
|
325
344
|
bgcolor = "0x1C1C1C"
|
326
345
|
url = f"https://maps.dwd.de/geoserver/dwd/wms?service=WMS&version=1.3.0&request=GetMap&layers={layers}&bbox={self._miny},{self._minx},{self._maxy},{self._maxx}&width={self._image_width}&height={self._image_height}&srs=EPSG:4326&styles=&format=image/png&TIME={date.strftime('%Y-%m-%dT%H:%M:00.0Z')}&bgcolor={bgcolor}"
|
327
346
|
request = requests.get(url, stream=True)
|
328
|
-
if request.status_code != 200
|
347
|
+
if request.status_code != 200:
|
329
348
|
raise ConnectionError(f"Error during image request from DWD servers: {url}")
|
349
|
+
elif request.headers["content-type"] != "image/png":
|
350
|
+
raise TypeError(
|
351
|
+
f"Unexpected content type: {request.headers['content-type']}"
|
352
|
+
)
|
330
353
|
try:
|
331
354
|
image = Image.open(BytesIO(request.content))
|
332
355
|
except Exception as e:
|
333
|
-
raise RuntimeError(
|
334
|
-
f"Error during image request from DWD servers: {url}"
|
335
|
-
) from e
|
356
|
+
raise RuntimeError(f"Error during image parsing: {url}") from e
|
336
357
|
image = draw_marker(
|
337
358
|
image,
|
338
359
|
ImageBoundaries(self._minx, self._maxx, self._miny, self._maxy),
|
{simple_dwd_weatherforecast-3.0.3.dist-info → simple_dwd_weatherforecast-3.0.5.dist-info}/RECORD
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
simple_dwd_weatherforecast/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
simple_dwd_weatherforecast/dwdforecast.py,sha256=
|
3
|
-
simple_dwd_weatherforecast/dwdmap.py,sha256=
|
2
|
+
simple_dwd_weatherforecast/dwdforecast.py,sha256=vUV1NquOJnX09f26kHSBLnGY7BhLXHaZ-Jsdc7Hr9Vk,39075
|
3
|
+
simple_dwd_weatherforecast/dwdmap.py,sha256=3R3ptBwBqTaLT2edDhkf4n7XPcvErHRbqq0U9BI41uI,14515
|
4
4
|
simple_dwd_weatherforecast/stations.json,sha256=1u8qc2CT_rVy49SAlOicGixzHln6Y0FXevuFAz2maBw,838948
|
5
5
|
simple_dwd_weatherforecast/uv_stations.json,sha256=ADenYo-aR6qbf0UFkfYr72kkFzL9HyUKe4VQ23POGF8,2292
|
6
|
-
simple_dwd_weatherforecast-3.0.
|
6
|
+
simple_dwd_weatherforecast-3.0.5.dist-info/licenses/LICENCE,sha256=27UG7gteqvSWuZlsbIq2_OAbh7VyifGGl-1zpuUoBcw,1072
|
7
7
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
tests/dummy_data.py,sha256=qapeQxjh8kURf5b-9h4gUdJaqQJQDVdqfMtS2g5JReY,103406
|
9
9
|
tests/dummy_data_full.py,sha256=3HRGAQBq4xPYs4jLzoLV_UAe1CXFzOsVBOouDL_5RHw,104062
|
@@ -36,7 +36,7 @@ tests/test_update.py,sha256=AIzzHMxcjwQjeTB0l3YFgB7HkGDbuqiHofwy41mS0m4,7440
|
|
36
36
|
tests/test_update_hourly.py,sha256=7Zl8ml3FTdqw3_Qwr_Tz-sWTzypvrBWmxeig2Vwp_ZQ,1781
|
37
37
|
tests/test_uv_index.py,sha256=tr6wnOyHlXT1S3yp1oeHc4-Brmc-EMEdM4mtyrdpcHg,579
|
38
38
|
tests/test_weather.py,sha256=ZyX4ldUoJpJp7YpiNQwU6Od-nYRay-3qcaDJdNq8fhY,780
|
39
|
-
simple_dwd_weatherforecast-3.0.
|
40
|
-
simple_dwd_weatherforecast-3.0.
|
41
|
-
simple_dwd_weatherforecast-3.0.
|
42
|
-
simple_dwd_weatherforecast-3.0.
|
39
|
+
simple_dwd_weatherforecast-3.0.5.dist-info/METADATA,sha256=2dKTCQf6QusYqGp9POHCNc0O6t7yhg5QFD-rFyJ8vrs,12869
|
40
|
+
simple_dwd_weatherforecast-3.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
41
|
+
simple_dwd_weatherforecast-3.0.5.dist-info/top_level.txt,sha256=iyEobUh14Tzitx39Oi8qm0NhBrnZovl_dNKtvLUkLEM,33
|
42
|
+
simple_dwd_weatherforecast-3.0.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|