simple-dwd-weatherforecast 3.0.0__py3-none-any.whl → 3.0.2__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.
@@ -181,13 +181,18 @@ def get_map(
181
181
  # Combine layers with special layers first, then map types, then other layers
182
182
  layers = f"{','.join(special_layers)},{map_layers},{','.join(other_layers)}".lstrip(
183
183
  ","
184
- )
184
+ ).rstrip(",")
185
185
 
186
186
  url = f"https://maps.dwd.de/geoserver/dwd/wms?service=WMS&version=1.3.0&request=GetMap&layers={layers}&bbox={miny},{minx},{maxy},{maxx}&width={image_width}&height={image_height}&srs=EPSG:4326&styles=&format=image/png"
187
- print(url)
187
+
188
188
  request = requests.get(url, stream=True)
189
189
  if request.status_code == 200:
190
- image = Image.open(BytesIO(request.content))
190
+ try:
191
+ image = Image.open(BytesIO(request.content))
192
+ except Exception as e:
193
+ raise RuntimeError(
194
+ f"Error during image request from DWD servers: {url}"
195
+ ) from e
191
196
  if dark_mode:
192
197
  new_image_data = []
193
198
  for item in image.getdata(): # type: ignore
@@ -202,6 +207,8 @@ def get_map(
202
207
  image.putdata(new_image_data)
203
208
  image = draw_marker(image, ImageBoundaries(minx, maxx, miny, maxy), markers)
204
209
  return image
210
+ else:
211
+ raise ConnectionError(f"Error during image request from DWD servers: {url}")
205
212
 
206
213
 
207
214
  class ImageLoop:
@@ -321,14 +328,18 @@ class ImageLoop:
321
328
  layers = (
322
329
  f"{','.join(special_layers)},{map_layers},{','.join(other_layers)}".lstrip(
323
330
  ","
324
- )
331
+ ).rstrip(",")
325
332
  )
326
333
  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')}"
327
- print(url)
328
334
  request = requests.get(url, stream=True)
329
335
  if request.status_code != 200 or request.headers["content-type"] != "image/png":
330
- raise ConnectionError("Error during image request from DWD servers")
331
- image = Image.open(BytesIO(request.content))
336
+ raise ConnectionError(f"Error during image request from DWD servers: {url}")
337
+ try:
338
+ image = Image.open(BytesIO(request.content))
339
+ except Exception as e:
340
+ raise RuntimeError(
341
+ f"Error during image request from DWD servers: {url}"
342
+ ) from e
332
343
  if self.dark_mode:
333
344
  new_image_data = []
334
345
  for item in image.getdata(): # type: ignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simple_dwd_weatherforecast
3
- Version: 3.0.0
3
+ Version: 3.0.2
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
2
  simple_dwd_weatherforecast/dwdforecast.py,sha256=uZRWMN9RIPvC9r47JAdw_AiP9V9M2rQxh_pOsVF15Sw,39094
3
- simple_dwd_weatherforecast/dwdmap.py,sha256=qy5RLp_WcuyhCOyypab9vP9qSpO4omoi-dPFLZ0kVBc,14096
3
+ simple_dwd_weatherforecast/dwdmap.py,sha256=Ib8fq3dDDxZqZUj6QjqHiC2vuOF3asYQnZAHqVdTsoQ,14532
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.0.dist-info/licenses/LICENCE,sha256=27UG7gteqvSWuZlsbIq2_OAbh7VyifGGl-1zpuUoBcw,1072
6
+ simple_dwd_weatherforecast-3.0.2.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.0.dist-info/METADATA,sha256=N4jyf6cS2laZrwPKQBYGFBj7tyXshpMKBmkAQhKalnc,12869
40
- simple_dwd_weatherforecast-3.0.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
41
- simple_dwd_weatherforecast-3.0.0.dist-info/top_level.txt,sha256=iyEobUh14Tzitx39Oi8qm0NhBrnZovl_dNKtvLUkLEM,33
42
- simple_dwd_weatherforecast-3.0.0.dist-info/RECORD,,
39
+ simple_dwd_weatherforecast-3.0.2.dist-info/METADATA,sha256=-2EyHuystf0JVnSWxDUfgYZ2w39REKwcyM6VOkHzm44,12869
40
+ simple_dwd_weatherforecast-3.0.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
41
+ simple_dwd_weatherforecast-3.0.2.dist-info/top_level.txt,sha256=iyEobUh14Tzitx39Oi8qm0NhBrnZovl_dNKtvLUkLEM,33
42
+ simple_dwd_weatherforecast-3.0.2.dist-info/RECORD,,