Closed nickbroon closed 5 years ago
Related traceback. Again probably due to failing to retrieve the weather.
Feb 28 09:12:17 raspberrypi weather.py[426]: Traceback (most recent call last):
Feb 28 09:12:17 raspberrypi weather.py[426]: File "/home/pi/breakout-garden/examples/weather/weather.py", line 107, in
Feb 28 09:12:17 raspberrypi weather.py[426]: weather = get_weather(location_string)
Feb 28 09:12:17 raspberrypi weather.py[426]: File "/home/pi/breakout-garden/examples/weather/weather.py", line 76, in
Feb 28 09:12:17 raspberrypi weather.py[426]: weather["summary"] = curr[0].img["alt"].split()[0]
Feb 28 09:12:17 raspberrypi weather.py[426]: IndexError: list index out of range
Added the following diff:
diff --git a/examples/weather/weather.py b/examples/weather/weather.py
index 320455f..5878b52 100755
--- a/examples/weather/weather.py
+++ b/examples/weather/weather.py
@@ -5,6 +5,7 @@ import os
import time
import datetime
import glob
+import logging
from PIL import Image
from PIL import ImageFont
@@ -15,6 +16,8 @@ import bme680
from luma.core.interface.serial import i2c
from luma.oled.device import sh1106
+logging.basicConfig(level=os.environ.get("LOGLEVEL", "WARNING"))
+
try:
import requests
except ImportError:
and get this error that then leads to traceback.
Feb 28 15:05:36 raspberrypi weather.py[3135]: ERROR:geocoder.base:Status code Unknown from https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find: ERROR - HTTPSConnectionPool(host='geocode.arcgis.com', port=443): Read timed out. (read timeout=5.0)
So looks the code needs to deal with coords
being None
I believe you fully patched this up in #10 - thank you!! Don't hesitate to re-open or pop up another issue if you have any other problems/suggestions.
Unfortunately it's not fully fixed. #10 just reduced the time frame during which it can happen. I think that's what needs is some exception handling (try ... except) around the url request calls to handle the case when they fail.
Occasional traceback in weather example
My best guess is that perhaps get_coords() or the requests.get() may occasionally fail. Perhaps some
try
exception handling around these is needed?