Compare commits
No commits in common. "24e82936a900c0c0508000dc7c96b31e6809a280" and "0f932fb93afc3ff44f8ba3223047b69743a49033" have entirely different histories.
24e82936a9
...
0f932fb93a
@ -1,141 +1,232 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
import os, sys
|
||||||
|
|
||||||
import os
|
# default installation
|
||||||
import sys
|
# core
|
||||||
from dataclasses import dataclass
|
# speech: speech-dispatcher
|
||||||
from typing import List, Optional
|
# sound: sox
|
||||||
|
# braille: brltty:
|
||||||
|
defaultInstallation = ['FenrirCore','vcsaDriver','dummyDriver (braille)','evdevDriver','genericDriver (speech)', 'genericDriver (sound)']
|
||||||
|
currentInstallation = []
|
||||||
|
|
||||||
@dataclass
|
print('checking dependencys...')
|
||||||
class Dependency:
|
# CORE
|
||||||
name: str
|
|
||||||
depType: str # screen, braille, input, sound, speech, core
|
|
||||||
moduleName: str
|
|
||||||
checkCommands: Optional[List[str]] = None # Command-line tools to check
|
|
||||||
pythonImports: Optional[List[str]] = None # Python packages to check
|
|
||||||
devicePaths: Optional[List[str]] = None # Device files to check
|
|
||||||
|
|
||||||
def check_dependency(dep: Dependency) -> bool:
|
|
||||||
"""Check if a single dependency is satisfied."""
|
|
||||||
isAvailable = True
|
|
||||||
|
|
||||||
if dep.pythonImports:
|
|
||||||
for package in dep.pythonImports:
|
|
||||||
try:
|
|
||||||
moduleName = package.split('.')[0]
|
|
||||||
__import__(moduleName)
|
|
||||||
print(f'{package}: OK')
|
|
||||||
except ImportError:
|
|
||||||
print(f'{package}: FAIL')
|
|
||||||
isAvailable = False
|
|
||||||
|
|
||||||
if dep.checkCommands:
|
|
||||||
for cmd in dep.checkCommands:
|
|
||||||
if os.path.exists(f'/usr/bin/{cmd}') or os.path.exists(f'/bin/{cmd}'):
|
|
||||||
print(f'{cmd}: OK')
|
|
||||||
else:
|
|
||||||
print(f'{cmd}: FAIL')
|
|
||||||
isAvailable = False
|
|
||||||
|
|
||||||
if dep.devicePaths:
|
|
||||||
for path in dep.devicePaths:
|
|
||||||
if os.path.exists(path):
|
|
||||||
print(f'{path}: OK')
|
|
||||||
else:
|
|
||||||
print(f'{path}: FAIL')
|
|
||||||
isAvailable = False
|
|
||||||
|
|
||||||
return isAvailable
|
|
||||||
|
|
||||||
# Define all dependencies
|
|
||||||
dependencyList = [
|
|
||||||
# Core dependencies
|
|
||||||
Dependency('FenrirCore', 'core', 'core',
|
|
||||||
pythonImports=['daemonize', 'enchant']),
|
|
||||||
|
|
||||||
# Screen drivers
|
|
||||||
Dependency('DummyScreen', 'screen', 'dummyDriver'),
|
|
||||||
Dependency('VCSA', 'screen', 'vcsaDriver',
|
|
||||||
pythonImports=['dbus'],
|
|
||||||
devicePaths=['/dev/vcsa']),
|
|
||||||
Dependency('PTY', 'screen', 'ptyDriver',
|
|
||||||
pythonImports=['pyte']),
|
|
||||||
|
|
||||||
# Braille drivers
|
|
||||||
Dependency('DummyBraille', 'braille', 'dummyDriver'),
|
|
||||||
Dependency('DebugBraille', 'braille', 'debugDriver'),
|
|
||||||
Dependency('BRLAPI', 'braille', 'brlapiDriver',
|
|
||||||
pythonImports=['brlapi']),
|
|
||||||
|
|
||||||
# Input drivers
|
|
||||||
Dependency('DummyInput', 'input', 'dummyDriver'),
|
|
||||||
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 = []
|
|
||||||
|
|
||||||
# Group dependencies by type for organized output
|
|
||||||
for depType in ['core', 'screen', 'braille', 'input', 'sound', 'speech']:
|
|
||||||
print(f'{depType.upper()} DRIVERS')
|
|
||||||
print('-' * 20)
|
|
||||||
|
|
||||||
depsOfType = [d for d in dependencyList if d.depType == depType]
|
|
||||||
for dep in depsOfType:
|
|
||||||
print(f'\nChecking {dep.name}:')
|
|
||||||
if check_dependency(dep):
|
|
||||||
availableModules.append(dep.name)
|
|
||||||
print('')
|
print('')
|
||||||
|
print('fenrir core:')
|
||||||
|
available = True
|
||||||
|
try:
|
||||||
|
from daemonize import Daemonize
|
||||||
|
print('python3-daemonize: OK')
|
||||||
|
except:
|
||||||
|
print('python3-daemonize: FAIL')
|
||||||
|
available = available and False
|
||||||
|
|
||||||
print_summary(availableModules)
|
try:
|
||||||
|
import enchant
|
||||||
|
print('pyenchant: OK')
|
||||||
|
except:
|
||||||
|
print('pyenchant: FAIL')
|
||||||
|
available = available and False
|
||||||
|
|
||||||
def print_summary(availableModules: List[str]):
|
if available:
|
||||||
print('=' * 20)
|
currentInstallation.append('FenrirCore')
|
||||||
print('SUMMARY')
|
|
||||||
print('=' * 20)
|
|
||||||
|
|
||||||
missingModules = defaultModules - set(availableModules)
|
# SCREEN
|
||||||
if missingModules:
|
print('--------------------')
|
||||||
print('Default Setup: FAIL')
|
print('screen driver')
|
||||||
print('\nUnavailable Default Modules:')
|
# dummy and debug
|
||||||
for module in missingModules:
|
print('dummyDriver (screen): OK')
|
||||||
print(f'- {module}')
|
currentInstallation.append('dummyDriver (screen)')
|
||||||
print('\nYou may need to install the missing dependencies for the modules above or reconfigure fenrir to not use them.')
|
|
||||||
|
# VCSA (screen driver)
|
||||||
|
print('vcsaDriver')
|
||||||
|
available = True
|
||||||
|
try:
|
||||||
|
import dbus
|
||||||
|
print('python3-dbus: OK')
|
||||||
|
except:
|
||||||
|
print('python3-dbus: FAIL')
|
||||||
|
available = available and False
|
||||||
|
if os.path.exists('/dev/vcsa'):
|
||||||
|
print('VCSA Device: OK')
|
||||||
else:
|
else:
|
||||||
|
print('VCSA Device: FAIL')
|
||||||
|
available = available and False
|
||||||
|
if available:
|
||||||
|
currentInstallation.append('vcsaDriver')
|
||||||
|
print('')
|
||||||
|
# pty emulation (screen driver)
|
||||||
|
print('ptyDriver')
|
||||||
|
available = True
|
||||||
|
try:
|
||||||
|
import pyte
|
||||||
|
print('pyte: OK')
|
||||||
|
except:
|
||||||
|
print('pyte: FAIL')
|
||||||
|
available = available and False
|
||||||
|
if available:
|
||||||
|
currentInstallation.append('ptyDriver (screen)')
|
||||||
|
|
||||||
|
# BRAILLE
|
||||||
|
print('--------------------')
|
||||||
|
print('braille driver')
|
||||||
|
# dummy and debug
|
||||||
|
print('dummyDriver (braille): OK')
|
||||||
|
currentInstallation.append('dummyDriver (braille)')
|
||||||
|
print('debugDriver (braille): OK')
|
||||||
|
currentInstallation.append('debugDriver (braille)')
|
||||||
|
# brltty (braille driver)
|
||||||
|
print('brlapiDriver')
|
||||||
|
available = True
|
||||||
|
try:
|
||||||
|
import brlapi
|
||||||
|
print('python3-brlapi: OK')
|
||||||
|
except:
|
||||||
|
print('python3-brlapi: FAIL')
|
||||||
|
available = available and False
|
||||||
|
|
||||||
|
if available:
|
||||||
|
currentInstallation.append('brlapiDriver')
|
||||||
|
# INPUT
|
||||||
|
print('--------------------')
|
||||||
|
print('input driver')
|
||||||
|
# dummy and debug
|
||||||
|
print('dummyDriver (input): OK')
|
||||||
|
currentInstallation.append('dummyDriver (input)')
|
||||||
|
print('debugDriver (input): OK')
|
||||||
|
currentInstallation.append('debugDriver (input)')
|
||||||
|
# evdev (input driver)
|
||||||
|
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('--------------------')
|
||||||
|
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
|
||||||
|
print('====================')
|
||||||
|
available = True
|
||||||
|
missing = []
|
||||||
|
for element in defaultInstallation:
|
||||||
|
if not element in currentInstallation:
|
||||||
|
available = False
|
||||||
|
missing.append(element)
|
||||||
|
if available:
|
||||||
print('Default Setup: OK')
|
print('Default Setup: OK')
|
||||||
|
else:
|
||||||
|
print('Default Setup: FAIL')
|
||||||
|
print('Unavailable Default Modules:')
|
||||||
|
for e in missing:
|
||||||
|
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()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user