do cleanups

This commit is contained in:
chrys 2016-10-08 11:45:17 +02:00
parent 556519187b
commit adc5384249

View File

@ -20,34 +20,42 @@ class driver():
return return
try: try:
self.connectDevice() self.connectDevice()
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('BRAILLE.connectDevice '+str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('BRAILLE.connectDevice '+str(e),debug.debugLevel.ERROR)
return return
self._isInitialized = True self._isInitialized = True
def flush(self): def flush(self):
if not self._isInitialized: if not self._isInitialized:
return return
try: try:
self._brl.writeText('',0) self._brl.writeText('',0)
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('BRAILLE.flush '+str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('BRAILLE.flush '+str(e),debug.debugLevel.ERROR)
def writeText(self,text): def writeText(self,text):
if not self._isInitialized: if not self._isInitialized:
return return
try: try:
self._brl.writeText(text) self._brl.writeText(text)
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('BRAILLE.writeText '+str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('BRAILLE.writeText '+str(e),debug.debugLevel.ERROR)
def connectDevice(self): def connectDevice(self):
self._brl = brlapi.Connection() self._brl = brlapi.Connection()
self._brl.enterTtyModeWithPath()
def enterTTY(self):
if not self._isInitialized:
return
self._brl.enterTtyModeWithPath()
def leveTTY(self):
if not self._isInitialized:
return
self._brl.leaveTtyMode()
def shutdown(self): def shutdown(self):
if not self._isInitialized: if not self._isInitialized:
return return
self._brl.leaveTtyMode() self.leveTTY()