add lock, initial outputManager

This commit is contained in:
chrys
2016-07-14 23:00:02 +02:00
parent 7b8d212af6
commit d9f8229aa5
13 changed files with 44 additions and 26 deletions

View File

@ -31,6 +31,7 @@ class commandManager():
return environment
def executeCommand(self, environment, currCommand, section = 'commands'):
environment = environment['commands'][section][currCommand].run(environment)
if self.isCommandDefined(environment):
try:
environ = environment['commands'][section][currCommand].run(environment)

View File

@ -13,6 +13,7 @@ class inputManager():
def getKeyPressed(self, environment):
try:
r, w, x = select(self.devices, [], [])
environment['runtime']['globalLock'].acquire(True)
currShortcut = environment['input']['currShortcut']
if r != []:
for fd in r:

View File

@ -3,13 +3,25 @@
class outputManager():
def __init__(self):
pass
def presentText(self, environment, Text):
pass
def speakText(self, environment, Text):
pass
def presentText(self, environment, Text, Interrupt=True):
self.speakText(environment, Text, Interrupt)
self.brailleText(environment, Text)
def speakText(self, environment, Text, Interrupt=True):
if environment['runtime']['speechDriver'] == None:
return
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
return
if Interrupt:
self.interruptOutput(environment)
environment['runtime']['speechDriver'].speak(Text)
def brailleText(self, environment, Text):
pass
def interruptOutput(self, environment, Text):
pass
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braile', 'enabled'):
return
print('braille')
def interruptOutput(self, environment):
environment['runtime']['speechDriver'].cancel()
def playSoundIcon(self, environment, Text):
pass

View File

@ -1,4 +1,5 @@
#!/bin/python
from _thread import allocate_lock
runtime = {
'speechDriver': None,
@ -7,4 +8,5 @@ runtime = {
'inputManager': None,
'commandManager': None,
'debug':None,
'globalLock': allocate_lock(),
}

View File

@ -3,6 +3,7 @@ import evdev
import importlib.util
from configparser import ConfigParser
from core import inputManager
from core import outputManager
from core import commandManager
from core import environment
from core.settings import settings
@ -80,10 +81,10 @@ class settingsManager():
return value
def getSettingAsInt(self, environment, section, setting):
return int(getSetting(self, environment, section, setting))
return int(self.getSetting( environment, section, setting))
def getSettingAsBool(self, environment, section, setting):
return bool(getSetting(self, environment, section, setting))
return bool(self.getSetting(environment, section, setting))
def loadSpeechDriver(self, environment, driverName):
if environment['runtime']['speechDriver'] != None:
@ -108,7 +109,8 @@ class settingsManager():
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
environment['runtime']['screenDriver'] = driver_mod.screen()
return environment
return environment
def initFenrirConfig(self):
return self.reInitFenrirConfig(environment.environment)
@ -116,6 +118,7 @@ class settingsManager():
environment['runtime']['settingsManager'] = self
environment['runtime']['inputManager'] = inputManager.inputManager()
environment['runtime']['outputManager'] = outputManager.outputManager()
environment = environment['runtime']['settingsManager'].loadShortcuts(environment)
environment = environment['runtime']['settingsManager'].loadSettings(environment)