simple-dwd-weatherforecast 3.0.2__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.
- simple_dwd_weatherforecast/dwdforecast.py +1 -2
- simple_dwd_weatherforecast/dwdmap.py +46 -44
- {simple_dwd_weatherforecast-3.0.2.dist-info → simple_dwd_weatherforecast-3.0.4.dist-info}/METADATA +1 -1
- {simple_dwd_weatherforecast-3.0.2.dist-info → simple_dwd_weatherforecast-3.0.4.dist-info}/RECORD +7 -7
- {simple_dwd_weatherforecast-3.0.2.dist-info → simple_dwd_weatherforecast-3.0.4.dist-info}/WHEEL +1 -1
- {simple_dwd_weatherforecast-3.0.2.dist-info → simple_dwd_weatherforecast-3.0.4.dist-info}/licenses/LICENCE +0 -0
- {simple_dwd_weatherforecast-3.0.2.dist-info → simple_dwd_weatherforecast-3.0.4.dist-info}/top_level.txt +0 -0
@@ -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:
|
@@ -182,8 +182,10 @@ def get_map(
|
|
182
182
|
layers = f"{','.join(special_layers)},{map_layers},{','.join(other_layers)}".lstrip(
|
183
183
|
","
|
184
184
|
).rstrip(",")
|
185
|
-
|
186
|
-
|
185
|
+
bgcolor = "0xFFFFFF"
|
186
|
+
if dark_mode:
|
187
|
+
bgcolor = "0x1C1C1C"
|
188
|
+
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&bgcolor={bgcolor}"
|
187
189
|
|
188
190
|
request = requests.get(url, stream=True)
|
189
191
|
if request.status_code == 200:
|
@@ -193,18 +195,6 @@ def get_map(
|
|
193
195
|
raise RuntimeError(
|
194
196
|
f"Error during image request from DWD servers: {url}"
|
195
197
|
) from e
|
196
|
-
if dark_mode:
|
197
|
-
new_image_data = []
|
198
|
-
for item in image.getdata(): # type: ignore
|
199
|
-
if item[0] == 255 and item[1] == 255 and item[2] == 255:
|
200
|
-
new_image_data.append((28, 28, 28))
|
201
|
-
elif item[0] == 85 and item[1] == 85 and item[2] == 85:
|
202
|
-
new_image_data.append((155, 155, 155))
|
203
|
-
else:
|
204
|
-
new_image_data.append(item)
|
205
|
-
|
206
|
-
# update image data
|
207
|
-
image.putdata(new_image_data)
|
208
198
|
image = draw_marker(image, ImageBoundaries(minx, maxx, miny, maxy), markers)
|
209
199
|
return image
|
210
200
|
else:
|
@@ -270,15 +260,7 @@ class ImageLoop:
|
|
270
260
|
now = get_time_last_5_min(datetime.now(timezone.utc))
|
271
261
|
self._last_update = now - timedelta(minutes=5) * self._steps
|
272
262
|
|
273
|
-
|
274
|
-
self._last_update += timedelta(minutes=5)
|
275
|
-
# Lightning in the NCEW_EU layer is only available in the last 5 minutes
|
276
|
-
self._images.append(
|
277
|
-
self._get_image(
|
278
|
-
self._last_update,
|
279
|
-
with_lightning=(now - self._last_update) < timedelta(minutes=5),
|
280
|
-
)
|
281
|
-
)
|
263
|
+
self._load_images(now)
|
282
264
|
|
283
265
|
def update(self):
|
284
266
|
now = get_time_last_5_min(datetime.now(timezone.utc))
|
@@ -288,11 +270,38 @@ class ImageLoop:
|
|
288
270
|
self._full_reload()
|
289
271
|
# Update the buffer and fetch only the new images
|
290
272
|
else:
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
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),
|
295
283
|
)
|
284
|
+
except ConnectionError as e:
|
285
|
+
raise ConnectionAbortedError(
|
286
|
+
f"Connection to DWD map servers failed: {e}"
|
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)
|
296
305
|
|
297
306
|
def _get_image(
|
298
307
|
self,
|
@@ -330,28 +339,21 @@ class ImageLoop:
|
|
330
339
|
","
|
331
340
|
).rstrip(",")
|
332
341
|
)
|
333
|
-
|
342
|
+
bgcolor = "0xFFFFFF"
|
343
|
+
if self.dark_mode:
|
344
|
+
bgcolor = "0x1C1C1C"
|
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}"
|
334
346
|
request = requests.get(url, stream=True)
|
335
|
-
if request.status_code != 200
|
347
|
+
if request.status_code != 200:
|
336
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
|
+
)
|
337
353
|
try:
|
338
354
|
image = Image.open(BytesIO(request.content))
|
339
355
|
except Exception as e:
|
340
|
-
raise RuntimeError(
|
341
|
-
f"Error during image request from DWD servers: {url}"
|
342
|
-
) from e
|
343
|
-
if self.dark_mode:
|
344
|
-
new_image_data = []
|
345
|
-
for item in image.getdata(): # type: ignore
|
346
|
-
if item[0] == 255 and item[1] == 255 and item[2] == 255:
|
347
|
-
new_image_data.append((28, 28, 28))
|
348
|
-
elif item[0] == 85 and item[1] == 85 and item[2] == 85:
|
349
|
-
new_image_data.append((155, 155, 155))
|
350
|
-
else:
|
351
|
-
new_image_data.append(item)
|
352
|
-
|
353
|
-
# update image data
|
354
|
-
image.putdata(new_image_data)
|
356
|
+
raise RuntimeError(f"Error during image parsing: {url}") from e
|
355
357
|
image = draw_marker(
|
356
358
|
image,
|
357
359
|
ImageBoundaries(self._minx, self._maxx, self._miny, self._maxy),
|
{simple_dwd_weatherforecast-3.0.2.dist-info → simple_dwd_weatherforecast-3.0.4.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=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.
|
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.
|
40
|
-
simple_dwd_weatherforecast-3.0.
|
41
|
-
simple_dwd_weatherforecast-3.0.
|
42
|
-
simple_dwd_weatherforecast-3.0.
|
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,,
|
File without changes
|
File without changes
|