Merge branch 'testing'

This commit is contained in:
Storm Dragon 2024-12-07 23:12:07 -05:00
commit 24e82936a9

View File

@ -1,232 +1,141 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os, sys
# default installation import os
# core import sys
# speech: speech-dispatcher from dataclasses import dataclass
# sound: sox from typing import List, Optional
# braille: brltty:
defaultInstallation = ['FenrirCore','vcsaDriver','dummyDriver (braille)','evdevDriver','genericDriver (speech)', 'genericDriver (sound)']
currentInstallation = []
print('checking dependencys...') @dataclass
# CORE class Dependency:
print('') name: str
print('fenrir core:') depType: str # screen, braille, input, sound, speech, core
available = True moduleName: str
try: checkCommands: Optional[List[str]] = None # Command-line tools to check
from daemonize import Daemonize pythonImports: Optional[List[str]] = None # Python packages to check
print('python3-daemonize: OK') devicePaths: Optional[List[str]] = None # Device files to check
except:
print('python3-daemonize: FAIL') def check_dependency(dep: Dependency) -> bool:
available = available and False """Check if a single dependency is satisfied."""
isAvailable = True
try: if dep.pythonImports:
import enchant for package in dep.pythonImports:
print('pyenchant: OK') try:
except: moduleName = package.split('.')[0]
print('pyenchant: FAIL') __import__(moduleName)
available = available and False print(f'{package}: OK')
except ImportError:
if available: print(f'{package}: FAIL')
currentInstallation.append('FenrirCore') isAvailable = False
# SCREEN
print('--------------------')
print('screen driver')
# dummy and debug
print('dummyDriver (screen): OK')
currentInstallation.append('dummyDriver (screen)')
# VCSA (screen driver) if dep.checkCommands:
print('vcsaDriver') for cmd in dep.checkCommands:
available = True if os.path.exists(f'/usr/bin/{cmd}') or os.path.exists(f'/bin/{cmd}'):
try: print(f'{cmd}: OK')
import dbus else:
print('python3-dbus: OK') print(f'{cmd}: FAIL')
except: isAvailable = False
print('python3-dbus: FAIL')
available = available and False if dep.devicePaths:
if os.path.exists('/dev/vcsa'): for path in dep.devicePaths:
print('VCSA Device: OK') if os.path.exists(path):
else: print(f'{path}: OK')
print('VCSA Device: FAIL') else:
available = available and False print(f'{path}: FAIL')
if available: isAvailable = False
currentInstallation.append('vcsaDriver')
print('') return isAvailable
# pty emulation (screen driver)
print('ptyDriver') # Define all dependencies
available = True dependencyList = [
try: # Core dependencies
import pyte Dependency('FenrirCore', 'core', 'core',
print('pyte: OK') pythonImports=['daemonize', 'enchant']),
except:
print('pyte: FAIL')
available = available and False
if available:
currentInstallation.append('ptyDriver (screen)')
# BRAILLE # Screen drivers
print('--------------------') Dependency('DummyScreen', 'screen', 'dummyDriver'),
print('braille driver') Dependency('VCSA', 'screen', 'vcsaDriver',
# dummy and debug pythonImports=['dbus'],
print('dummyDriver (braille): OK') devicePaths=['/dev/vcsa']),
currentInstallation.append('dummyDriver (braille)') Dependency('PTY', 'screen', 'ptyDriver',
print('debugDriver (braille): OK') pythonImports=['pyte']),
currentInstallation.append('debugDriver (braille)')
# brltty (braille driver) # Braille drivers
print('brlapiDriver') Dependency('DummyBraille', 'braille', 'dummyDriver'),
available = True Dependency('DebugBraille', 'braille', 'debugDriver'),
try: Dependency('BRLAPI', 'braille', 'brlapiDriver',
import brlapi pythonImports=['brlapi']),
print('python3-brlapi: OK')
except: # Input drivers
print('python3-brlapi: FAIL') Dependency('DummyInput', 'input', 'dummyDriver'),
available = available and False Dependency('DebugInput', 'input', 'debugDriver'),
Dependency('Evdev', 'input', 'evdevDriver',
pythonImports=['evdev', 'evdev.InputDevice', 'evdev.UInput', 'pyudev']),
Dependency('PTYInput', 'input', 'ptyDriver',
pythonImports=['pyte']),
# Sound drivers
Dependency('DummySound', 'sound', 'dummyDriver'),
Dependency('DebugSound', 'sound', 'debugDriver'),
Dependency('GenericSound', 'sound', 'genericDriver',
checkCommands=['play', 'sox']),
Dependency('GStreamer', 'sound', 'gstreamerDriver',
pythonImports=['gi', 'gi.repository.GLib', 'gi.repository.Gst']),
# Speech drivers
Dependency('DummySpeech', 'speech', 'dummyDriver'),
Dependency('DebugSpeech', 'speech', 'debugDriver'),
Dependency('Speechd', 'speech', 'speechdDriver',
pythonImports=['speechd']),
Dependency('GenericSpeech', 'speech', 'genericDriver',
checkCommands=['espeak-ng'])
]
defaultModules = {
'FenrirCore',
'VCSA',
'DummyBraille',
'Evdev',
'GenericSpeech',
'GenericSound'
}
def check_all_dependencies():
print('Checking dependencies...\n')
availableModules = []
if available: # Group dependencies by type for organized output
currentInstallation.append('brlapiDriver') for depType in ['core', 'screen', 'braille', 'input', 'sound', 'speech']:
# INPUT print(f'{depType.upper()} DRIVERS')
print('--------------------') print('-' * 20)
print('input driver')
# dummy and debug depsOfType = [d for d in dependencyList if d.depType == depType]
print('dummyDriver (input): OK') for dep in depsOfType:
currentInstallation.append('dummyDriver (input)') print(f'\nChecking {dep.name}:')
print('debugDriver (input): OK') if check_dependency(dep):
currentInstallation.append('debugDriver (input)') availableModules.append(dep.name)
# evdev (input driver) print('')
print('evdevDriver')
available = True
try:
import evdev
from evdev import InputDevice, UInput
print('python3-evdev: OK')
except:
print('python3-evdev: FAIL')
available = available and False
try:
import pyudev
print('python3-pyudev: OK')
except:
print('python3-pyudev: FAIL')
available = available and False
if available:
currentInstallation.append('evdevDriver')
# pty emulation (input driver)
print('')
print('ptyDriver')
available = True
try:
import pyte
print('pyte: OK')
except:
print('pyte: FAIL')
available = available and False
if available:
currentInstallation.append('ptyDriver (Input)')
# SOUND
print('--------------------')
print('sound driver')
# dummy and debug
print('dummyDriver (sound): OK')
currentInstallation.append('dummyDriver (sound)')
print('debugDriver (sound): OK')
currentInstallation.append('debugDriver (sound)')
print('genericDriver (uses sox by default)')
available = True
if os.path.exists('/usr/bin/play') and os.path.exists('/usr/bin/sox'):
print('sox: OK')
else:
print('sox: FAIL')
available = available and False
if available:
currentInstallation.append('genericDriver (sound)')
print('')
# gstreamer (sound driver)
print('gstreamerDriver')
available = True
try:
import gi
print('gi: OK')
except:
print('gi: FAIL')
available = available and False
try:
from gi.repository import GLib
print('gi GLib: OK')
except:
print('gi GLib: FAIL')
available = available and False
try:
gi.require_version('Gst', '1.0')
from gi.repository import Gst
print('gi Gst: OK')
except:
print('gi Gst: FAIL')
available = available and False
if available:
currentInstallation.append('gstreamerDriver')
# SPEECH print_summary(availableModules)
print('--------------------')
print('speech driver')
# dummy and debug
print('dummyDriver (speech): OK')
currentInstallation.append('dummyDriver (speech)')
print('debugDriver (speech): OK')
currentInstallation.append('debugDriver (speech)')
# speechd (speech driver)
print('speechdDriver')
available = True
try:
import speechd
print('python3-speechd: OK')
except:
print('python3-speechd: FAIL')
available = available and False
if available:
currentInstallation.append('speechdDriver')
print('')
# espeak (speech driver)
print('espeakDriver')
available = True
try:
from espeak import espeak
print('python3-espeak: OK')
except:
print('python3-espeak: FAIL')
available = available and False
if available:
currentInstallation.append('espeakDriver')
print('genericDriver (uses espeak-ng by default)')
available = True
if os.path.exists('/usr/bin/espeak-ng') or os.path.exists('/bin/espeak-ng'):
print('espeak-ng: OK')
else:
print('espeak-ng: FAIL')
available = available and False
if available:
currentInstallation.append('genericDriver (speech)')
# SUMMERY def print_summary(availableModules: List[str]):
print('====================') print('=' * 20)
available = True print('SUMMARY')
missing = [] print('=' * 20)
for element in defaultInstallation:
if not element in currentInstallation: missingModules = defaultModules - set(availableModules)
available = False if missingModules:
missing.append(element) print('Default Setup: FAIL')
if available: print('\nUnavailable Default Modules:')
print('Default Setup: OK') for module in missingModules:
else: print(f'- {module}')
print('Default Setup: FAIL') print('\nYou may need to install the missing dependencies for the modules above or reconfigure fenrir to not use them.')
print('Unavailable Default Modules:') else:
for e in missing: print('Default Setup: OK')
print(e)
print('you may need to install the missing dependencys for the modules above or reconfigure fenrir to not use them')
print('')
print('Available Modules:')
for element in currentInstallation:
print(element)
print('\nAvailable Modules:')
for module in availableModules:
print(f'- {module}')
if __name__ == '__main__':
check_all_dependencies()