Skip to content

Commit 41a44da

Browse files
committed
revise exception handling - again - remove extra lines
1 parent a67ad99 commit 41a44da

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

adafruit_sht31.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,8 @@ def _data(self):
8787
data[0] = 0xff
8888
self._command(SHT31_MEAS_HIGHREP)
8989
time.sleep(.5)
90-
try:
91-
with self.i2c_device as i2c:
92-
i2c.readinto(data)
93-
except OSError:
94-
raise
90+
with self.i2c_device as i2c:
91+
i2c.readinto(data)
9592
temperature, tcheck, humidity, hcheck = struct.unpack('>HBHB', data)
9693
if tcheck != _crc(data[:2]):
9794
raise RuntimeError("temperature CRC mismatch")
@@ -133,11 +130,7 @@ def status(self):
133130
"""Return the Sensor status."""
134131
data = bytearray(2)
135132
self._command(SHT31_READSTATUS)
136-
try:
137-
with self.i2c_device as i2c:
138-
i2c.readinto(data)
139-
except OSError as error:
140-
if error.args[0] not in ('I2C bus error', 19): # errno 19 ENODEV
141-
raise
133+
with self.i2c_device as i2c:
134+
i2c.readinto(data)
142135
status = data[0] << 8 | data[1]
143136
return status

examples/sht31_simpletest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@
2121
time.sleep(1)
2222
sensor.heater = False
2323
print("Sensor Heater status =", sensor.heater)
24-

0 commit comments

Comments
 (0)