From 05d820334ac4c8ecc90ce740af10b7578c1ad254 Mon Sep 17 00:00:00 2001 From: HaseHarald Date: Sat, 15 Apr 2023 16:20:29 +0200 Subject: [PATCH] fix(weather_press_/temp_): Cast url-read object to string The read function on an urllib urlopen object returns an object as a response. Regular expressions using re can't be used on such objects. This causes the following error: ``` Traceback (most recent call last): File "/tmp/weather/./weather_press_LOWW", line 43, in hpa = re_hpa.findall(txt)[0] TypeError: cannot use a string pattern on a bytes-like object ``` This can be easily fixed, because said object can simply be cast to string. Which is, what this patch does for both the US NOAA based plugins. --- plugins/weather/weather_press_ | 2 +- plugins/weather/weather_temp_ | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/weather/weather_press_ b/plugins/weather/weather_press_ index 12cc9936..7ce091d9 100755 --- a/plugins/weather/weather_press_ +++ b/plugins/weather/weather_press_ @@ -37,7 +37,7 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config": print('graph_scale no') else: u = urlopen(url % code) - txt = u.read() + txt = str(u.read()) u.close() hpa = re_hpa.findall(txt)[0] diff --git a/plugins/weather/weather_temp_ b/plugins/weather/weather_temp_ index 2d28b436..d0e9c606 100755 --- a/plugins/weather/weather_temp_ +++ b/plugins/weather/weather_temp_ @@ -37,7 +37,7 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config": print('graph_args --base 1000 -l 0') else: u = urlopen(url % code) - txt = u.read() + txt = str(u.read()) u.close() C = re_C.findall(txt)[0]