add first trigger

This commit is contained in:
chrys
2016-07-12 23:09:11 +02:00
parent 0fb493e391
commit 6f84710b6f
11 changed files with 144 additions and 35 deletions

View File

@ -25,7 +25,10 @@ class commandManager():
except:
continue
return environment
def executeTriggerCommands(self, environment, trigger):
for cmd in sorted(environment['commands'][trigger]):
environment = environment['commands'][trigger][cmd].run(environment)
return environment
def executeCommand(self, environment, currCommand, section = 'commands'):
if self.isCommandDefined(environment):
try:

View File

@ -8,12 +8,10 @@ commandInfo = {
}
commands = {
'onnInput':{
'onInput':{
},
'onScreenChanged':{
},
'commands':{
# 'curr_line': curr_line.command(),
# 'shut_up': shut_up.command()
}
}

View File

@ -3,12 +3,13 @@
screenData = {
'columns': 0,
'lines': 0,
'delta': '',
'oldDelta': '',
'oldCursorReview':{'x':0,'y':0},
'oldCursor':{'x':0,'y':0},
'oldContentBytes': b'',
'oldContentText': '',
'oldContentAttrib': b'',
'newDelta': '',
'newCursorReview':{'x':0,'y':0},
'newCursor':{'x':0,'y':0},
'newContentBytes': b'',

View File

@ -2,10 +2,11 @@
from configparser import ConfigParser
from core.settings import settings
import evdev
import importlib.util
class settingsManager():
def __init__(self):
pass
self.settings = settings
def loadShortcuts(self, environment, kbConfigPath='../../config/keyboard/desktop.kb'):
kbConfig = open(kbConfigPath,"r")
@ -66,7 +67,43 @@ class settingsManager():
environment['settings'].read(settingConfigPath)
return environment
def getSetting(self, environment, setting):
value = True # do be implemented
def getSetting(self, environment, section, setting):
value = ''
try:
value = environment['settings'].get(section, setting)
except:
value = self.settings[section][setting]
return value
def getSettingAsInt(self, environment, section, setting):
return int(getSetting(self, environment, section, setting))
def getSettingAsBool(self, environment, section, setting):
return bool(getSetting(self, environment, section, setting))
def loadSpeechDriver(self, environment, driverName):
if environment['runtime']['speechDriver'] != None:
environment['runtime']['speechDriver'].shutdown()
spec = importlib.util.spec_from_file_location(driverName, 'speech/' + driverName + '.py')
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
environment['runtime']['speechDriver'] = driver_mod.speech()
return environment
def loadSoundDriver(self, environment, driverName):
if environment['runtime']['soundDriver'] != None:
environment['runtime']['soundDriver'].shutdown()
spec = importlib.util.spec_from_file_location(driverName, 'sound/' + driverName + '.py')
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
environment['runtime']['soundDriver'] = driver_mod.sound()
return environment
def loadScreenDriver(self, environment, driverName):
spec = importlib.util.spec_from_file_location(driverName, 'screen/' + driverName + '.py')
driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod)
environment['runtime']['screenDriver'] = driver_mod.screen()
return environment