simple-dwd-weatherforecast 3.0.3__py3-none-any.whl → 3.0.4__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.
@@ -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
- print("no report for this station available")
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
- while now > self._last_update:
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
- while now > self._last_update:
282
- self._last_update += timedelta(minutes=5)
283
- self._images.append(
284
- self._get_image(self._last_update, with_lightning=True)
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 or request.headers["content-type"] != "image/png":
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),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simple_dwd_weatherforecast
3
- Version: 3.0.3
3
+ Version: 3.0.4
4
4
  Summary: A simple tool to retrieve a weather forecast from DWD OpenData
5
5
  Home-page: https://github.com/FL550/simple_dwd_weatherforecast.git
6
6
  Author: Max Fermor
@@ -1,9 +1,9 @@
1
1
  simple_dwd_weatherforecast/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- simple_dwd_weatherforecast/dwdforecast.py,sha256=uZRWMN9RIPvC9r47JAdw_AiP9V9M2rQxh_pOsVF15Sw,39094
3
- simple_dwd_weatherforecast/dwdmap.py,sha256=I_C0MPK7RlbtNGOpxGl5Oy4rm-XEB_gIbLunV0y76HI,13691
2
+ simple_dwd_weatherforecast/dwdforecast.py,sha256=UJopfqrI13qV27nLgSS0GZY6_qPQ7S5ZWqiI-PGT9bo,39081
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.3.dist-info/licenses/LICENCE,sha256=27UG7gteqvSWuZlsbIq2_OAbh7VyifGGl-1zpuUoBcw,1072
6
+ simple_dwd_weatherforecast-3.0.4.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.3.dist-info/METADATA,sha256=kDbBjTJiY0xUAJnDea87paaLvhAaX3UAmC_du1w0w3U,12869
40
- simple_dwd_weatherforecast-3.0.3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
41
- simple_dwd_weatherforecast-3.0.3.dist-info/top_level.txt,sha256=iyEobUh14Tzitx39Oi8qm0NhBrnZovl_dNKtvLUkLEM,33
42
- simple_dwd_weatherforecast-3.0.3.dist-info/RECORD,,
39
+ simple_dwd_weatherforecast-3.0.4.dist-info/METADATA,sha256=UinjW8wBvFNYCsBrVGP1bGBxiyXJz4cdYiXOGQlDCOc,12869
40
+ simple_dwd_weatherforecast-3.0.4.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
41
+ simple_dwd_weatherforecast-3.0.4.dist-info/top_level.txt,sha256=iyEobUh14Tzitx39Oi8qm0NhBrnZovl_dNKtvLUkLEM,33
42
+ simple_dwd_weatherforecast-3.0.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5