Skip to content

Commit 53e94f5

Browse files
authored
Merge pull request #2227 from dhalbert/pyplanter-fixes
Fix PyPlanter; update other catches of requests exceptions
2 parents 24436a1 + 9eb5844 commit 53e94f5

File tree

40 files changed

+51
-50
lines changed

40 files changed

+51
-50
lines changed

Adafruit_IO_Air_Quality/code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def read_bme(is_celsius=False):
168168
# Hourly reset
169169
if cur_time.tm_min == 0:
170170
prv_mins = 0
171-
except (ValueError, RuntimeError) as e:
171+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
172172
print("Failed to fetch time, retrying\n", e)
173173
wifi.reset()
174174
wifi.connect()
@@ -200,7 +200,7 @@ def read_bme(is_celsius=False):
200200
io.send_data(feed_temperature["key"], str(temperature))
201201
io.send_data(feed_humidity["key"], str(humidity))
202202
print("Published!")
203-
except (ValueError, RuntimeError) as e:
203+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
204204
print("Failed to send data to IO, retrying\n", e)
205205
wifi.reset()
206206
wifi.connect()

Adafruit_IO_Power_Relay/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def on_relay_msg(client, topic, value):
129129
while True:
130130
try: # Poll for new messages on feed_relay
131131
client.loop()
132-
except (ValueError, RuntimeError) as e:
132+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
133133
print("Failed to get data, retrying\n", e)
134134
wifi.reset()
135135
client.reconnect()

Adafruit_IO_Power_Relay/code_light_sensor/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def on_relay_msg(client, topic, value):
169169
print("Published!")
170170
prv_sensor_value = sensor_value
171171
start_time = now
172-
except (ValueError, RuntimeError) as e:
172+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
173173
print("Failed to get data, retrying\n", e)
174174
wifi.reset()
175175
client.reconnect()

Adafruit_IO_Schedule_Trigger/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def on_relay_msg(client, topic, message):
141141
while True:
142142
try:
143143
io.loop()
144-
except (ValueError, RuntimeError) as e:
144+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
145145
print("Failed to get data, retrying\n", e)
146146
wifi.reset()
147147
io.reconnect()

Bitcoin_Matrix/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def text_transform(val):
5151
try:
5252
value = matrixportal.fetch()
5353
print("Response is", value)
54-
except (ValueError, RuntimeError) as e:
54+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
5555
print("Some error occured, retrying! -", e)
5656

5757
time.sleep(3 * 60) # wait 3 minutes

Feather_ESP32-S2_TFT_Azure/code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@
216216
device.loop()
217217
# if something disrupts the loop, reconnect
218218
# pylint: disable=broad-except
219-
except (ValueError, RuntimeError, OSError, Exception) as e:
220-
print("Connection error, reconnecting\n", str(e))
219+
except (ValueError, RuntimeError, OSError, ConnectionError) as e:
220+
print("Network error, reconnecting\n", str(e))
221221
supervisor.reload()
222222
continue
223223
# delay

MagTag_AdafruitQuotes/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
try:
3737
value = magtag.fetch()
3838
print("Response is", value)
39-
except (ValueError, RuntimeError) as e:
39+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
4040
print("Some error occured, retrying! -", e)
4141
timestamp = time.monotonic()

MagTag_Cheerlights/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@
4343
magtag.peripherals.neopixels.fill(color)
4444
external_pixels.fill(color)
4545
timestamp = time.monotonic()
46-
except (ValueError, RuntimeError) as e:
46+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
4747
print("Some error occured, retrying! -", e)
4848
time.sleep(1)

MagTag_Cheerlights_LED_Animations/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
)
138138

139139
timestamp = time.monotonic()
140-
except (ValueError, RuntimeError) as e:
140+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
141141
# Catch any random errors so the code will continue running.
142142
print("Some error occured, retrying! -", e)
143143
try:

MagTag_CountdownCelebration/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
seconds = int(datetime_str[17:19])
6161
rtc.RTC().datetime = time.struct_time((year, month, mday, hours, minutes, seconds, 0, 0, False))
6262
lasttimefetch_stamp = time.monotonic()
63-
except (ValueError, RuntimeError) as e:
63+
except (ValueError, RuntimeError, ConnectionError, OSError) as e:
6464
print("Some error occured, retrying! -", e)
6565
continue
6666

0 commit comments

Comments
 (0)