Updated shabang to use env python3
This commit is contained in:
parent
af857d7976
commit
295167c865
@ -1,41 +1,85 @@
|
||||
#!/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
import brlapi
|
||||
from fenrirscreenreader.core import debug
|
||||
|
||||
class brailleDriver():
|
||||
def __init__(self):
|
||||
self._isInitialized = False
|
||||
self.deviceSize = None
|
||||
self._brl = None
|
||||
|
||||
def initialize(self, environment):
|
||||
"""Initialize the BRLTTY connection."""
|
||||
self.env = environment
|
||||
try:
|
||||
self._brl = brlapi.Connection()
|
||||
self._brl.enterTtyMode()
|
||||
self.deviceSize = self._brl.displaySize
|
||||
self._isInitialized = True
|
||||
return True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Initializing braille failed:' + str(e),debug.debugLevel.ERROR)
|
||||
return False
|
||||
|
||||
def getDeviceSize(self):
|
||||
"""Get the size of the braille display."""
|
||||
if not self._isInitialized:
|
||||
return (0,0)
|
||||
return (0,0)
|
||||
return (0, 0)
|
||||
return self.deviceSize if self.deviceSize else (0, 0)
|
||||
|
||||
def writeText(self,text):
|
||||
def writeText(self, text):
|
||||
"""Write text to the braille display."""
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
# Ensure text doesn't exceed display width
|
||||
if self.deviceSize:
|
||||
text = text[:self.deviceSize[0]]
|
||||
self._brl.writeText(text)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Writing braille failed:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def connectDevice(self):
|
||||
pass
|
||||
"""Attempt to connect to the braille device."""
|
||||
try:
|
||||
if self._brl:
|
||||
self._brl.enterTtyMode()
|
||||
return True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Connecting braille failed:' + str(e),debug.debugLevel.ERROR)
|
||||
return False
|
||||
|
||||
def enterScreen(self, screen):
|
||||
"""Enter a new screen context."""
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
self._brl.enterTtyModeWithPath(screen)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Entering screen failed:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def leveScreen(self):
|
||||
def leaveScreen(self):
|
||||
"""Leave the current screen context."""
|
||||
if not self._isInitialized:
|
||||
return
|
||||
try:
|
||||
self._brl.leaveTtyMode()
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Leaving screen failed:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def shutdown(self):
|
||||
"""Shutdown the braille driver."""
|
||||
if not self._isInitialized:
|
||||
return
|
||||
self.leveScreen()
|
||||
try:
|
||||
self.leaveScreen()
|
||||
if self._brl:
|
||||
self._brl.closeConnection()
|
||||
self._brl = None
|
||||
self._isInitialized = False
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('ERROR: Shutting down braille failed:' + str(e),debug.debugLevel.ERROR)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from enum import Enum
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# Debugger module for the Fenrir screen reader.
|
||||
|
||||
from fenrirscreenreader.core import debug
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import configparser
|
||||
import os
|
||||
|
Loading…
Reference in New Issue
Block a user