File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 99import re
1010from io import BytesIO
1111import typing
12- from typing import Dict , List , Set
12+ from typing import Dict , List , Optional , Set
1313
1414import serial
1515
@@ -97,7 +97,7 @@ def isSeikaBluetoothDeviceMatch(match: DeviceMatch) -> bool:
9797
9898
9999class 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 )
You can’t perform that action at this time.
0 commit comments