1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 22:25:23 +00:00

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 <module>
    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.
This commit is contained in:
HaseHarald 2023-04-15 16:20:29 +02:00
parent 885708a826
commit 05d820334a
2 changed files with 2 additions and 2 deletions

View file

@ -37,7 +37,7 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config":
print('graph_scale no') print('graph_scale no')
else: else:
u = urlopen(url % code) u = urlopen(url % code)
txt = u.read() txt = str(u.read())
u.close() u.close()
hpa = re_hpa.findall(txt)[0] hpa = re_hpa.findall(txt)[0]

View file

@ -37,7 +37,7 @@ elif len(sys.argv) == 2 and sys.argv[1] == "config":
print('graph_args --base 1000 -l 0') print('graph_args --base 1000 -l 0')
else: else:
u = urlopen(url % code) u = urlopen(url % code)
txt = u.read() txt = str(u.read())
u.close() u.close()
C = re_C.findall(txt)[0] C = re_C.findall(txt)[0]