Updated shabang to use env python3

This commit is contained in:
Storm Dragon 2024-12-05 14:51:05 -05:00
parent af857d7976
commit 295167c865
11 changed files with 65 additions and 21 deletions

View File

@ -1,41 +1,85 @@
#!/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers. # By Chrys, Storm Dragon, and contributors.
import brlapi
from fenrirscreenreader.core import debug from fenrirscreenreader.core import debug
class brailleDriver(): class brailleDriver():
def __init__(self): def __init__(self):
self._isInitialized = False self._isInitialized = False
self.deviceSize = None self.deviceSize = None
self._brl = None
def initialize(self, environment): def initialize(self, environment):
"""Initialize the BRLTTY connection."""
self.env = environment self.env = environment
self._isInitialized = True 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): def getDeviceSize(self):
"""Get the size of the braille display."""
if not self._isInitialized: 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: if not self._isInitialized:
return 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): 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): def enterScreen(self, screen):
"""Enter a new screen context."""
if not self._isInitialized: if not self._isInitialized:
return 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: if not self._isInitialized:
return 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): def shutdown(self):
"""Shutdown the braille driver."""
if not self._isInitialized: if not self._isInitialized:
return return
self.leveScreen() try:
self._isInitialized = False 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)

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
from enum import Enum from enum import Enum

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# Debugger module for the Fenrir screen reader. # Debugger module for the Fenrir screen reader.
from fenrirscreenreader.core import debug from fenrirscreenreader.core import debug

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Fenrir TTY screen reader # Fenrir TTY screen reader

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python3
import configparser import configparser
import os import os