simple-dwd-weatherforecast 3.0.3__tar.gz → 3.0.4__tar.gz
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-3.0.3/simple_dwd_weatherforecast.egg-info → simple_dwd_weatherforecast-3.0.4}/PKG-INFO +1 -1
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/setup.py +1 -1
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast/dwdforecast.py +1 -2
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast/dwdmap.py +38 -17
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4/simple_dwd_weatherforecast.egg-info}/PKG-INFO +1 -1
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/LICENCE +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/README.md +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/setup.cfg +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast/__init__.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast/stations.json +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast/uv_stations.json +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast.egg-info/SOURCES.txt +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast.egg-info/dependency_links.txt +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast.egg-info/requires.txt +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/simple_dwd_weatherforecast.egg-info/top_level.txt +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/__init__.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/dummy_data.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/dummy_data_full.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/dummy_uv.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_avg.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_condition.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_max.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_min.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_sum.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_day_values.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_forecast_condition.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_forecast_data.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_station_name.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_timeframe_avg.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_timeframe_condition.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_timeframe_max.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_timeframe_min.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_timeframe_sum.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_timeframe_values.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_is_in_timerange.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_is_valid_timeframe.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_location_tools.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_map.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_parsekml.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_region.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_reported_weather.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_station.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_stationsfile.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_update.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_update_hourly.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_uv_index.py +0 -0
- {simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_weather.py +0 -0
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
5
5
|
|
6
6
|
setuptools.setup(
|
7
7
|
name="simple_dwd_weatherforecast",
|
8
|
-
version="v3.0.
|
8
|
+
version="v3.0.4",
|
9
9
|
author="Max Fermor",
|
10
10
|
description="A simple tool to retrieve a weather forecast from DWD OpenData",
|
11
11
|
long_description=long_description,
|
@@ -421,8 +421,7 @@ class Weather:
|
|
421
421
|
|
422
422
|
def get_reported_weather(self, weatherDataType: WeatherDataType, shouldUpdate=True):
|
423
423
|
if not self.has_measurement(self.station_id):
|
424
|
-
|
425
|
-
return None
|
424
|
+
raise ValueError("No report for this station available")
|
426
425
|
if shouldUpdate:
|
427
426
|
self.update(with_measurements=True)
|
428
427
|
if self.report_data is not None:
|
@@ -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),
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/dummy_data_full.py
RENAMED
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_avg.py
RENAMED
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_max.py
RENAMED
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_min.py
RENAMED
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_daily_sum.py
RENAMED
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_day_values.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_get_station_name.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_is_in_timerange.py
RENAMED
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_location_tools.py
RENAMED
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_parsekml.py
RENAMED
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_reported_weather.py
RENAMED
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_stationsfile.py
RENAMED
File without changes
|
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_update_hourly.py
RENAMED
File without changes
|
{simple_dwd_weatherforecast-3.0.3 → simple_dwd_weatherforecast-3.0.4}/tests/test_uv_index.py
RENAMED
File without changes
|
File without changes
|