Skip to content

Commit 72ce6ec

Browse files
authored
Merge 4b398d4 into 64301ba
2 parents 64301ba + 4b398d4 commit 72ce6ec

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

source/braille.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,13 +2427,13 @@ def terminate(self):
24272427
Subclasses should call the superclass method first.
24282428
@postcondition: This instance can no longer be used unless it is constructed again.
24292429
"""
2430-
super(BrailleDisplayDriver,self).terminate()
2430+
super().terminate()
24312431
# Clear the display.
24322432
try:
24332433
self.display([0] * self.numCells)
2434-
except:
2434+
except Exception as e:
24352435
# The display driver seems to be failing, but we're terminating anyway, so just ignore it.
2436-
pass
2436+
log.debugWarning(f"Display driver {self} is failing while terminating. {e}")
24372437

24382438
#: typing information for autoproperty _get_numCells
24392439
numCells: int

source/brailleDisplayDrivers/seikantk.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import re
1010
from io import BytesIO
1111
import typing
12-
from typing import Dict, List, Set
12+
from typing import Dict, List, Optional, Set
1313

1414
import serial
1515

@@ -97,7 +97,7 @@ def isSeikaBluetoothDeviceMatch(match: DeviceMatch) -> bool:
9797

9898

9999
class BrailleDisplayDriver(braille.BrailleDisplayDriver):
100-
_dev: hwIo.IoBase
100+
_dev: Optional[hwIo.IoBase] = None
101101
name = SEIKA_NAME
102102
# Translators: Name of a braille display.
103103
description = _("Seika Notetaker")
@@ -185,12 +185,18 @@ def _getDeviceInfo(self, dev: hwIo.IoBase) -> bool:
185185
return False
186186

187187
def terminate(self):
188+
if self._dev is None:
189+
log.error("Seika Notetaker driver not initialized")
190+
return
188191
try:
189192
super().terminate()
190193
finally:
191194
self._dev.close()
192195

193196
def display(self, cells: List[int]):
197+
if self._dev is None:
198+
log.error("Seika Notetaker driver not initialized")
199+
return
194200
# cells will already be padded up to numCells.
195201
cellBytes = SEIKA_SEND_TEXT + bytes([self.numCells]) + bytes(cells)
196202
self._dev.write(cellBytes)

0 commit comments

Comments
 (0)