Skip to content

Commit 6a89566

Browse files
committed
Correcting examples
1 parent 6c6e553 commit 6a89566

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

examples/all-in-one.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def get_cpu_temperature():
198198
try:
199199
data = pms5003.read()
200200
except pmsReadTimeoutError:
201-
logging.warn("Failed to read PMS5003")
201+
logging.warning("Failed to read PMS5003")
202202
else:
203203
data = float(data.pm_ug_per_m3(1.0))
204204
display_text(variables[mode], data, unit)
@@ -209,7 +209,7 @@ def get_cpu_temperature():
209209
try:
210210
data = pms5003.read()
211211
except pmsReadTimeoutError:
212-
logging.warn("Failed to read PMS5003")
212+
logging.warning("Failed to read PMS5003")
213213
else:
214214
data = float(data.pm_ug_per_m3(2.5))
215215
display_text(variables[mode], data, unit)
@@ -220,7 +220,7 @@ def get_cpu_temperature():
220220
try:
221221
data = pms5003.read()
222222
except pmsReadTimeoutError:
223-
logging.warn("Failed to read PMS5003")
223+
logging.warning("Failed to read PMS5003")
224224
else:
225225
data = float(data.pm_ug_per_m3(10))
226226
display_text(variables[mode], data, unit)

examples/combined.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import ltr559
1313

1414
from bme280 import BME280
15-
from pms5003 import PMS5003, ReadTimeoutError as pmsReadTimeoutError
15+
from pms5003 import PMS5003, ReadTimeoutError as pmsReadTimeoutError, SerialTimeoutError
1616
from enviroplus import gas
1717
from subprocess import PIPE, Popen
1818
from PIL import Image
@@ -276,7 +276,7 @@ def main():
276276
try:
277277
data = pms5003.read()
278278
except pmsReadTimeoutError:
279-
logging.warn("Failed to read PMS5003")
279+
logging.warning("Failed to read PMS5003")
280280
else:
281281
data = float(data.pm_ug_per_m3(1.0))
282282
display_text(variables[mode], data, unit)
@@ -287,7 +287,7 @@ def main():
287287
try:
288288
data = pms5003.read()
289289
except pmsReadTimeoutError:
290-
logging.warn("Failed to read PMS5003")
290+
logging.warning("Failed to read PMS5003")
291291
else:
292292
data = float(data.pm_ug_per_m3(2.5))
293293
display_text(variables[mode], data, unit)
@@ -298,7 +298,7 @@ def main():
298298
try:
299299
data = pms5003.read()
300300
except pmsReadTimeoutError:
301-
logging.warn("Failed to read PMS5003")
301+
logging.warning("Failed to read PMS5003")
302302
else:
303303
data = float(data.pm_ug_per_m3(10))
304304
display_text(variables[mode], data, unit)
@@ -331,8 +331,8 @@ def main():
331331
pms_data = None
332332
try:
333333
pms_data = pms5003.read()
334-
except pmsReadTimeoutError:
335-
logging.warn("Failed to read PMS5003")
334+
except (SerialTimeoutError, pmsReadTimeoutError):
335+
logging.warning("Failed to read PMS5003")
336336
else:
337337
save_data(7, float(pms_data.pm_ug_per_m3(1.0)))
338338
save_data(8, float(pms_data.pm_ug_per_m3(2.5)))

0 commit comments

Comments
 (0)