Merge branch 'remotesetting'

This commit is contained in:
chrys 2018-09-09 15:26:22 +02:00
commit 79b4ac32fb
17 changed files with 420 additions and 76 deletions

View File

@ -122,7 +122,6 @@ driver=vcsaDriver
encoding=auto encoding=auto
screenUpdateDelay=0.05 screenUpdateDelay=0.05
suspendingScreen= suspendingScreen=
suspendingScreenFile=/tmp/fenrirSuspend
autodetectSuspendingScreen=True autodetectSuspendingScreen=True
[keyboard] [keyboard]
@ -187,6 +186,21 @@ shell=
cursor=True cursor=True
highlight=False highlight=False
[remote]
enable=True
# connection type
# unix = unix sockets
# tcp = tcp (localhost only)
method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite
enableSettingsRemote=True
# allow commands to be executed
enableCommandRemote=True
[barrier] [barrier]
enabled=True enabled=True
leftBarriers=│└┌─ leftBarriers=│└┌─

View File

@ -124,7 +124,6 @@ driver=vcsaDriver
encoding=auto encoding=auto
screenUpdateDelay=0.05 screenUpdateDelay=0.05
suspendingScreen= suspendingScreen=
suspendingScreenFile=/tmp/fenrirSuspend
autodetectSuspendingScreen=True autodetectSuspendingScreen=True
[keyboard] [keyboard]
@ -197,6 +196,21 @@ cursor=True
#follow highlighted text changes #follow highlighted text changes
highlight=False highlight=False
[remote]
enable=True
# connection type
# unix = unix sockets
# tcp = tcp (localhost only)
method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite
enableSettingsRemote=True
# allow commands to be executed
enableCommandRemote=True
[barrier] [barrier]
enabled=True enabled=True
leftBarriers=│└┌─ leftBarriers=│└┌─

View File

@ -125,7 +125,6 @@ driver=vcsaDriver
encoding=auto encoding=auto
screenUpdateDelay=0.05 screenUpdateDelay=0.05
suspendingScreen= suspendingScreen=
suspendingScreenFile=/tmp/fenrirSuspend
autodetectSuspendingScreen=True autodetectSuspendingScreen=True
[keyboard] [keyboard]
@ -198,6 +197,21 @@ cursor=True
#follow highlighted text changes #follow highlighted text changes
highlight=False highlight=False
[remote]
enable=True
# connection type
# unix = unix sockets
# tcp = tcp (localhost only)
method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite
enableSettingsRemote=True
# allow commands to be executed
enableCommandRemote=True
[barrier] [barrier]
enabled=True enabled=True
leftBarriers=│└┌─ leftBarriers=│└┌─

View File

@ -79,7 +79,6 @@ driver=vcsaDriver
encoding=auto encoding=auto
screenUpdateDelay=0.05 screenUpdateDelay=0.05
suspendingScreen= suspendingScreen=
suspendingScreenFile=/tmp/fenrirSuspend
autodetectSuspendingScreen=True autodetectSuspendingScreen=True
[keyboard] [keyboard]
@ -143,6 +142,21 @@ cursor=True
#follow highlighted text changes #follow highlighted text changes
highlight=False highlight=False
[remote]
enable=True
# connection type
# unix = unix sockets
# tcp = tcp (localhost only)
method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite
enableSettingsRemote=True
# allow commands to be executed
enableCommandRemote=True
[barrier] [barrier]
enabled=True enabled=True
leftBarriers=│└┌─ leftBarriers=│└┌─

View File

@ -124,7 +124,6 @@ driver=vcsaDriver
encoding=auto encoding=auto
screenUpdateDelay=0.05 screenUpdateDelay=0.05
suspendingScreen= suspendingScreen=
suspendingScreenFile=/tmp/fenrirSuspend
autodetectSuspendingScreen=True autodetectSuspendingScreen=True
[keyboard] [keyboard]
@ -197,6 +196,21 @@ cursor=True
#follow highlighted text changes #follow highlighted text changes
highlight=False highlight=False
[remote]
enable=True
# connection type
# unix = unix sockets
# tcp = tcp (localhost only)
method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite
enableSettingsRemote=True
# allow commands to be executed
enableCommandRemote=True
[barrier] [barrier]
enabled=True enabled=True
leftBarriers=│└┌─ leftBarriers=│└┌─

13
realese nots/1.9.3 Normal file
View File

@ -0,0 +1,13 @@
- fix hight CPU load in VCSA pressing mute key
- add remote manager
- remote manager: TCP connection
- remote manager: UNIX Socket connection(default)
- remote manager: set settings set a setting (-o syntax) "setting set sound#enabled=False"
- remote manager: reset settings "setting reset"
- remote manager: save settings "setting save /path/settings.conf"
- remote Manager: say command (say something) "command say this is a test"
- remote manager: interrupt command (interrupt current speech) "command interrupt"
- remote manager: window command (to define window) "command window startX startY endX endY"
- remote manager: resetwindow command (to reset window) "command resetwindow"
- settings: store settings more centralized
- variouse speedups and bugfixes

View File

@ -35,17 +35,17 @@ class byteManager():
if eventData == b'': if eventData == b'':
return return
convertedEscapeSequence = self.unifyEscapeSeq(eventData) convertedEscapeSequence = self.unifyEscapeSeq(eventData)
if self.switchCtrlModeOnce > 0: if self.switchCtrlModeOnce > 0:
self.switchCtrlModeOnce -= 1 self.switchCtrlModeOnce -= 1
isControlMode = False isControlMode = False
if self.controlMode and not self.switchCtrlModeOnce == 1 or\ if self.controlMode and not self.switchCtrlModeOnce == 1 or\
not self.controlMode: not self.controlMode:
isControlMode = self.handleControlMode(eventData) isControlMode = self.handleControlMode(eventData)
isCommand = False isCommand = False
if self.controlMode and not self.switchCtrlModeOnce == 1 or\ if self.controlMode and not self.switchCtrlModeOnce == 1 or\
not self.controlMode and self.switchCtrlModeOnce == 1: not self.controlMode and self.switchCtrlModeOnce == 1:
if self.lastByteKey == convertedEscapeSequence: if self.lastByteKey == convertedEscapeSequence:
@ -53,16 +53,16 @@ class byteManager():
self.repeat += 1 self.repeat += 1
shortcutData = b'' shortcutData = b''
for i in range(self.repeat): for i in range(self.repeat):
shortcutData = shortcutData + convertedEscapeSequence shortcutData = shortcutData + convertedEscapeSequence
isCommand = self.detectByteCommand(shortcutData) isCommand = self.detectByteCommand(shortcutData)
# fall back to single stroke - do we want this? # fall back to single stroke - do we want this?
if not isCommand: if not isCommand:
isCommand = self.detectByteCommand(convertedEscapeSequence) isCommand = self.detectByteCommand(convertedEscapeSequence)
self.repeat = 1 self.repeat = 1
if not (isCommand or isControlMode): if not (isCommand or isControlMode):
self.env['runtime']['screenManager'].injectTextToScreen(eventData) self.env['runtime']['screenManager'].injectTextToScreen(eventData)
if not isCommand: if not isCommand:
self.repeat = 1 self.repeat = 1
self.lastByteKey = convertedEscapeSequence self.lastByteKey = convertedEscapeSequence
self.lastInputTime = time.time() self.lastInputTime = time.time()
def getLastByteKey(self): def getLastByteKey(self):

View File

@ -82,21 +82,40 @@ class cursorManager():
except: except:
pass pass
return False return False
def setWindowForApplication(self): def setWindowForApplication(self, start = None, end = None):
if not self.env['commandBuffer']['Marks']['1']: x1 = 0
return False x2 = 0
if not self.env['commandBuffer']['Marks']['2']: y1 = 0
return False y2 = 0
if start == None:
if not self.env['commandBuffer']['Marks']['1']:
return False
else:
x1 = self.env['commandBuffer']['Marks']['1']['x']
y1 = self.env['commandBuffer']['Marks']['1']['y']
else:
x1 = start['x']
y1 = start['y']
if end == None:
if not self.env['commandBuffer']['Marks']['2']:
return False
else:
x1 = self.env['commandBuffer']['Marks']['2']['x']
y1 = self.env['commandBuffer']['Marks']['2']['y']
else:
x1 = start['x']
y1 = start['y']
currApp = self.env['runtime']['applicationManager'].getCurrentApplication() currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
self.env['commandBuffer']['windowArea'][currApp] = {} self.env['commandBuffer']['windowArea'][currApp] = {}
if self.env['commandBuffer']['Marks']['1']['x'] * self.env['commandBuffer']['Marks']['1']['y'] <= \ if x1 * y1 <= \
self.env['commandBuffer']['Marks']['2']['x'] * self.env['commandBuffer']['Marks']['2']['y']: x2 * y2:
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x1, 'y':y1}
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x2, 'y':y2}
else: else:
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['2'].copy() self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x2, 'y':y2}
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['1'].copy() self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x1, 'y':y1}
return True return True
def clearWindowForApplication(self): def clearWindowForApplication(self):
currApp = self.env['runtime']['applicationManager'].getCurrentApplication() currApp = self.env['runtime']['applicationManager'].getCurrentApplication()

View File

@ -18,7 +18,8 @@ class fenrirEventType(Enum):
ScreenChanged = 7 ScreenChanged = 7
HeartBeat = 8 # for time based scheduling HeartBeat = 8 # for time based scheduling
ExecuteCommand = 9 ExecuteCommand = 9
ByteInput = 10 ByteInput = 10
RemoteIncomming = 11
def __int__(self): def __int__(self):
return self.value return self.value
def __str__(self): def __str__(self):

View File

@ -29,7 +29,7 @@ class eventManager():
#print('NET loop ' + str(time.time() - st)) #print('NET loop ' + str(time.time() - st))
def eventDispatcher(self, event): def eventDispatcher(self, event):
self.env['runtime']['debug'].writeDebugOut('eventManager:eventDispatcher:start: event: ' + str(event['Type']),debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('eventManager:eventDispatcher:start: event: ' + str(event['Type']),debug.debugLevel.INFO)
if not event: if not event:
return return
if not event['Type']: if not event['Type']:
@ -55,7 +55,9 @@ class eventManager():
elif event['Type'] == fenrirEventType.ExecuteCommand: elif event['Type'] == fenrirEventType.ExecuteCommand:
self.env['runtime']['fenrirManager'].handleExecuteCommand(event) self.env['runtime']['fenrirManager'].handleExecuteCommand(event)
elif event['Type'] == fenrirEventType.ByteInput: elif event['Type'] == fenrirEventType.ByteInput:
self.env['runtime']['fenrirManager'].handleByteInput(event) self.env['runtime']['fenrirManager'].handleByteInput(event)
elif event['Type'] == fenrirEventType.RemoteIncomming:
self.env['runtime']['fenrirManager'].handleRemoteIncomming(event)
def isMainEventLoopRunning(self): def isMainEventLoopRunning(self):
return self.running.value == 1 return self.running.value == 1
def startMainEventLoop(self): def startMainEventLoop(self):
@ -77,9 +79,9 @@ class eventManager():
except Empty: except Empty:
pass pass
def getEventQueue(self): def getEventQueue(self):
return self._eventQueue return self._eventQueue
def getRunning(self): def getRunning(self):
return self.running return self.running
def putToEventQueue(self,event, data): def putToEventQueue(self,event, data):
if not isinstance(event, fenrirEventType): if not isinstance(event, fenrirEventType):
return False return False

View File

@ -105,6 +105,10 @@ class fenrirManager():
self.environment['runtime']['commandManager'].executeCommand( command, 'help') self.environment['runtime']['commandManager'].executeCommand( command, 'help')
return return
self.environment['runtime']['commandManager'].executeCommand( command, 'commands') self.environment['runtime']['commandManager'].executeCommand( command, 'commands')
def handleRemoteIncomming(self, event):
if not event['Data']:
return
self.environment['runtime']['remoteManager'].handleRemoteIncomming(event['Data'])
def handleScreenChange(self, event): def handleScreenChange(self, event):
self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data']) self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data'])
''' '''

View File

@ -0,0 +1,208 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
'''
Remote controll:
section<space>command<space>parameters
sections:command,setting
setting commands:
- set section#setting=value[,section#setting=value]
- reset
command commands:
- say text to speech
- interrupt
examples
settings:
settings set section#setting=value[,section#setting=value]
setting set speech#voice=de
setting reset
setting save /path/settings.conf
command:
command say this is a test
command interrupt
'''
from fenrirscreenreader.core import debug
from fenrirscreenreader.core.eventData import fenrirEventType
import time
import select
import socket
import os, os.path
class remoteManager():
def __init__(self):
# command controll
self.commandConst = 'COMMAND '
self.sayConst = 'SAY '
self.interruptConst = 'INTERRUPT'
self.defineWindowConst = 'WINDOW '
self.resetWindowConst = 'RESETWINDOW'
# setting controll
self.settingConst = 'SETTING '
self.setSettingConst = 'SET '
self.saveSettingConst = 'SAVE '
self.resetSettingConst = 'RESET'
def initialize(self, environment):
self.env = environment
if self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enabled'):
if self.env['runtime']['settingsManager'].getSetting('remote', 'method').upper() == 'UNIX':
self.env['runtime']['processManager'].addCustomEventThread(self.unixSocketWatchDog, multiprocess=True)
elif self.env['runtime']['settingsManager'].getSetting('remote', 'method').upper() == 'TCP':
self.env['runtime']['processManager'].addCustomEventThread(self.tcpWatchDog, multiprocess=True)
def shutdown(self):
if self.sock:
self.sock.close()
self.sock = None
def unixSocketWatchDog(self, active, eventQueue):
# echo "command say this is a test" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock
if self.env['runtime']['settingsManager'].getSetting('screen', 'driver') =='vcsaDriver':
socketpath = self.env['runtime']['settingsManager'].getSettingAsInt('remote', 'socketpath') + 'fenrirscreenreader-deamon.sock'
else:
socketpath = self.env['runtime']['settingsManager'].getSettingAsInt('remote', 'socketpath') + 'fenrirscreenreader-' + str(os.getpid()) + '.sock'
if os.path.exists(socketpath):
os.remove(socketpath)
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.bind(socketpath)
self.sock.listen(1)
if self.env['runtime']['settingsManager'].getSetting('screen', 'driver') =='vcsaDriver':
os.chmod(socketpath, 0o222)
while active.value == 1:
client_sock, client_addr = self.sock.accept()
if client_sock:
# Check if the client is still connected and if data is available:
try:
r, w, e = select.select([client_sock,], [], [])
except select.error:
return
if len(r) > 0:
rawdata = client_sock.recv(8129)
try:
data = rawdata.decode("utf-8").rstrip().lstrip()
eventQueue.put({"Type":fenrirEventType.RemoteIncomming,
"Data": data
})
except:
pass
client_sock.close()
if os.path.exists(socketpath):
os.remove(socketpath)
if self.sock:
self.sock.close()
self.sock = None
def tcpWatchDog(self, active, eventQueue):
# echo "command say this is a test" | nc localhost 22447
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.host = '127.0.0.1'
self.port = self.env['runtime']['settingsManager'].getSettingAsInt('remote', 'port')
self.sock.bind((self.host, self.port))
self.sock.listen(1)
while active.value == 1:
client_sock, client_addr = self.sock.accept()
if client_sock:
# Check if the client is still connected and if data is available:
try:
r, w, e = select.select([client_sock,], [], [])
except select.error:
return
if len(r) > 0:
rawdata = client_sock.recv(8129)
try:
data = rawdata.decode("utf-8").rstrip().lstrip()
eventQueue.put({"Type":fenrirEventType.RemoteIncomming,
"Data": data
})
except:
pass
client_sock.close()
if self.sock:
self.sock.close()
self.sock = None
def handleSettingsChange(self, settingsText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableSettingsRemote'):
return
upperSettingsText = settingsText.upper()
# set setting
if upperSettingsText.startswith(self.setSettingConst):
parameterText = settingsText[len(self.setSettingConst):]
self.setSettings(parameterText)
# save setting
if upperSettingsText.startswith(self.saveSettingConst):
parameterText = settingsText[len(self.saveSettingConst):]
self.saveSettings(parameterText)
# reset setting
if upperSettingsText.startswith(self.resetSettingConst):
self.resetSettings()
def handleCommandExecution(self, commandText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableCommandRemote'):
return
upperCommandText = commandText.upper()
# say
if upperCommandText.startswith(self.sayConst):
parameterText = commandText[len(self.sayConst):]
self.say(parameterText)
# interrupt
if upperCommandText.startswith(self.interruptConst):
self.interruptSpeech()
# define window
if upperCommandText.startswith(self.defineWindowConst):
parameterText = commandText[len(self.defineWindowConst):]
self.defineWindow(parameterText)
# reset window
if upperCommandText.startswith(self.resetWindowConst):
self.resetWindow()
def defineWindow(self, windowText):
start = {}
end = {}
try:
windowList = windowText.split(' ')
if len(windowList) < 4:
return
start['x'] = int(windowList[0])
start['y'] = int(windowList[1])
end['x'] = int(windowList[2])
end['y'] = int(windowList[3])
self.env['runtime']['cursorManager'].setWindowForApplication(start, end)
except Exception as e:
pass
def resetWindow(self):
self.env['runtime']['cursorManager'].clearWindowForApplication()
def say(self, text):
if not text:
return
if text == '':
return
self.env['runtime']['outputManager'].speakText(text)
def interruptSpeech(self):
self.env['runtime']['outputManager'].interruptOutput()
def saveSettings(self, settingConfigPath):
if not settingConfigPath:
return
if settingConfigPath == '':
return
self.env['runtime']['settingsManager'].saveSettings(settingConfigPath)
def resetSettings(self):
self.env['runtime']['settingsManager'].resetSettingArgDict()
def setSettings(self, settingsArgs):
self.env['runtime']['settingsManager'].parseSettingArgs(settingsArgs)
def handleRemoteIncomming(self, eventData):
if not eventData:
return
upperEventData = eventData.upper()
if upperEventData.startswith(self.settingConst):
settingsText = eventData[len(self.settingConst):]
self.handleSettingsChange(settingsText)
elif upperEventData.startswith(self.commandConst):
commandText = eventData[len(self.commandConst):]
self.handleCommandExecution(commandText)

View File

@ -195,15 +195,7 @@ class screenManager():
if fixIgnoreScreens != '': if fixIgnoreScreens != '':
ignoreScreens.extend(fixIgnoreScreens.split(',')) ignoreScreens.extend(fixIgnoreScreens.split(','))
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'): if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'):
ignoreScreens.extend(self.env['screen']['autoIgnoreScreens']) ignoreScreens.extend(self.env['screen']['autoIgnoreScreens'])
try:
ignoreFileName = self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreenFile')
if ignoreFileName != '':
if os.access(ignoreFileName, os.R_OK):
with open(ignoreFileName) as fp:
ignoreScreens.extend(fp.read().replace('\n','').split(','))
except:
pass
self.env['runtime']['debug'].writeDebugOut('screenManager:isSuspendingScreen ignore:' + str(ignoreScreens) + ' current:'+ str(screen ), debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('screenManager:isSuspendingScreen ignore:' + str(ignoreScreens) + ' current:'+ str(screen ), debug.debugLevel.INFO)
return (screen in ignoreScreens) return (screen in ignoreScreens)
@ -214,7 +206,7 @@ class screenManager():
def isDelta(self, ignoreSpace=False): def isDelta(self, ignoreSpace=False):
newDelta = self.env['screen']['newDelta'] newDelta = self.env['screen']['newDelta']
if ignoreSpace: if ignoreSpace:
newDelta = newDelta.strip() newDelta = newDelta.strip()
return newDelta != '' return newDelta != ''
def isNegativeDelta(self): def isNegativeDelta(self):
return self.env['screen']['newNegativeDelta'] != '' return self.env['screen']['newNegativeDelta'] != ''

View File

@ -51,7 +51,6 @@ settingsData = {
'encoding': 'auto', 'encoding': 'auto',
'screenUpdateDelay': 0.1, 'screenUpdateDelay': 0.1,
'suspendingScreen': '', 'suspendingScreen': '',
'suspendingScreenFile': '/tmp/fenrirSuspend',
'autodetectSuspendingScreen': False, 'autodetectSuspendingScreen': False,
}, },
'general':{ 'general':{
@ -80,7 +79,14 @@ settingsData = {
'focus':{ 'focus':{
'cursor': True, 'cursor': True,
'highlight': False, 'highlight': False,
},
'remote':{
'enabled': True,
'method': 'unix',
'port': 22447,
'socketpath':'/tmp/',
'enableSettingsRemote': True,
'enableCommandRemote': True,
}, },
'barrier':{ 'barrier':{
'enabled': True, 'enabled': True,

View File

@ -5,6 +5,7 @@
# By Chrys, Storm Dragon, and contributers. # By Chrys, Storm Dragon, and contributers.
import os, inspect import os, inspect
currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe())))) currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe()))))
fenrirPath = os.path.dirname(currentdir) fenrirPath = os.path.dirname(currentdir)
@ -26,6 +27,7 @@ from fenrirscreenreader.core import tableManager
from fenrirscreenreader.core import byteManager from fenrirscreenreader.core import byteManager
from fenrirscreenreader.core import attributeManager from fenrirscreenreader.core import attributeManager
from fenrirscreenreader.core import barrierManager from fenrirscreenreader.core import barrierManager
from fenrirscreenreader.core import remoteManager
from fenrirscreenreader.core import environment from fenrirscreenreader.core import environment
from fenrirscreenreader.core.settingsData import settingsData from fenrirscreenreader.core.settingsData import settingsData
from fenrirscreenreader.core import debug from fenrirscreenreader.core import debug
@ -77,18 +79,35 @@ class settingsManager():
self.env['settings'] = ConfigParser() self.env['settings'] = ConfigParser()
self.env['settings'].read(settingConfigPath) self.env['settings'].read(settingConfigPath)
return True return True
def saveSettings(self, settingConfigPath):
# set opt dict here
# save file
try:
#print('file: ',settingConfigPath)
for section, settings in self.settingArgDict.items():
for setting, value in settings.items():
#print(section, setting, value)
self.env['settings'].set(section, setting, value)
#print('full',self.env['settings'])
configFile = open(settingConfigPath, 'w')
self.env['settings'].write(configFile)
configFile.close()
os.chmod(settingConfigPath, 0o666)
except Exception as e:
self.env['runtime']['debug'].writeDebugOut('saveSettings: save settingsfile:' + settingConfigPath + 'failed. Error:' + str(e), debug.debugLevel.ERROR)
def setSetting(self, section, setting, value): def setSetting(self, section, setting, value):
self.env['settings'].set(section, setting, value) self.setOptionArgDict(section, setting, value)
#self.env['settings'].set(section, setting, value)
def getSetting(self, section, setting): def getSetting(self, section, setting):
value = '' value = ''
try: try:
value = self.settingArgDict[section.lower()][setting.lower()] value = self.settingArgDict[section.lower()][setting.lower()]
return value return value
except: except:
pass pass
try: try:
value = self.env['settings'].get(section, setting) value = self.env['settings'].get(section, setting)
except: except:
value = str(self.settings[section][setting]) value = str(self.settings[section][setting])
@ -98,7 +117,7 @@ class settingsManager():
value = 0 value = 0
try: try:
value = int(self.settingArgDict[section.lower()][setting.lower()]) value = int(self.settingArgDict[section.lower()][setting.lower()])
return value return value
except Exception as e: except Exception as e:
pass pass
try: try:
@ -111,9 +130,9 @@ class settingsManager():
value = 0.0 value = 0.0
try: try:
value = float(self.settingArgDict[section.lower()][setting.lower()]) value = float(self.settingArgDict[section.lower()][setting.lower()])
return value return value
except Exception as e: except Exception as e:
pass pass
try: try:
value = self.env['settings'].getfloat(section, setting) value = self.env['settings'].getfloat(section, setting)
except: except:
@ -158,8 +177,8 @@ class settingsManager():
try: try:
self.env['runtime'][driverType].shutdown() self.env['runtime'][driverType].shutdown()
except Exception as e: except Exception as e:
pass pass
del self.env['runtime'][driverType] del self.env['runtime'][driverType]
def setFenrirKeys(self, keys): def setFenrirKeys(self, keys):
keys = keys.upper() keys = keys.upper()
@ -173,6 +192,8 @@ class settingsManager():
for key in keyList: for key in keyList:
if not key in self.env['input']['scriptKey']: if not key in self.env['input']['scriptKey']:
self.env['input']['scriptKey'].append(key) self.env['input']['scriptKey'].append(key)
def resetSettingArgDict(self):
self.settingArgDict = {}
def setOptionArgDict(self, section, option, value): def setOptionArgDict(self, section, option, value):
section = section.lower() section = section.lower()
option = option.lower() option = option.lower()
@ -180,17 +201,18 @@ class settingsManager():
e = self.settingArgDict[section] e = self.settingArgDict[section]
except KeyError: except KeyError:
self.settingArgDict[section] = {} self.settingArgDict[section] = {}
self.settingArgDict[section][option] = str(value) self.settingArgDict[section][option] = str(value)
def parseSettingArgs(self, settingArgs): def parseSettingArgs(self, settingArgs):
for optionElem in settingArgs.split(';'): for optionElem in settingArgs.split(';'):
if len(optionElem.split('#',1)) != 2: if len(optionElem.split('#',1)) != 2:
continue continue
if len(optionElem.split('#',1)[1].split('=',1)) != 2: if len(optionElem.split('#',1)[1].split('=',1)) != 2:
continue continue
section = str(optionElem.split('#',1)[0]).lower() section = str(optionElem.split('#',1)[0]).lower()
option = str(optionElem.split('#',1)[1].split('=',1)[0]).lower() option = str(optionElem.split('#',1)[1].split('=',1)[0]).lower()
value = optionElem.split('#',1)[1].split('=',1)[1] value = optionElem.split('#',1)[1].split('=',1)[1]
self.setOptionArgDict(section, option, value) self.setOptionArgDict(section, option, value)
def initFenrirConfig(self, cliArgs, fenrirManager = None, environment = environment.environment): def initFenrirConfig(self, cliArgs, fenrirManager = None, environment = environment.environment):
@ -208,7 +230,7 @@ class settingsManager():
if os.path.exists(settingsRoot + '/settings/settings.conf'): if os.path.exists(settingsRoot + '/settings/settings.conf'):
settingsFile = settingsRoot + '/settings/settings.conf' settingsFile = settingsRoot + '/settings/settings.conf'
else: else:
return None return None
# get sound themes root # get sound themes root
if not os.path.exists(soundRoot): if not os.path.exists(soundRoot):
if os.path.exists(fenrirPath + '/../../config/sound/'): if os.path.exists(fenrirPath + '/../../config/sound/'):
@ -234,12 +256,12 @@ class settingsManager():
#self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty') #self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty')
self.setSetting('keyboard', 'keyboardLayout', 'pty') self.setSetting('keyboard', 'keyboardLayout', 'pty')
self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log') self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log')
if cliArgs.emulated_evdev: if cliArgs.emulated_evdev:
self.setOptionArgDict('screen', 'driver', 'ptyDriver') self.setOptionArgDict('screen', 'driver', 'ptyDriver')
self.setOptionArgDict('keyboard', 'driver', 'evdevDriver') self.setOptionArgDict('keyboard', 'driver', 'evdevDriver')
self.setFenrirKeys(self.getSetting('general','fenrirKeys')) self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
self.setScriptKeys(self.getSetting('general','scriptKeys')) self.setScriptKeys(self.getSetting('general','scriptKeys'))
environment['runtime']['debug'] = debugManager.debugManager(self.env['runtime']['settingsManager'].getSetting('general','debugFile')) environment['runtime']['debug'] = debugManager.debugManager(self.env['runtime']['settingsManager'].getSetting('general','debugFile'))
environment['runtime']['debug'].initialize(environment) environment['runtime']['debug'].initialize(environment)
@ -268,39 +290,43 @@ class settingsManager():
else: else:
environment['runtime']['punctuationManager'].loadDicts(self.getSetting('general','punctuationProfile')) environment['runtime']['punctuationManager'].loadDicts(self.getSetting('general','punctuationProfile'))
if fenrirManager: if fenrirManager:
environment['runtime']['fenrirManager'] = fenrirManager environment['runtime']['fenrirManager'] = fenrirManager
environment['runtime']['memoryManager'] = memoryManager.memoryManager() environment['runtime']['memoryManager'] = memoryManager.memoryManager()
environment['runtime']['memoryManager'].initialize(environment) environment['runtime']['memoryManager'].initialize(environment)
environment['runtime']['attributeManager'] = attributeManager.attributeManager() environment['runtime']['attributeManager'] = attributeManager.attributeManager()
environment['runtime']['attributeManager'].initialize(environment) environment['runtime']['attributeManager'].initialize(environment)
environment['runtime']['eventManager'] = eventManager.eventManager() environment['runtime']['eventManager'] = eventManager.eventManager()
environment['runtime']['eventManager'].initialize(environment) environment['runtime']['eventManager'].initialize(environment)
environment['runtime']['processManager'] = processManager.processManager() environment['runtime']['processManager'] = processManager.processManager()
environment['runtime']['processManager'].initialize(environment) environment['runtime']['processManager'].initialize(environment)
environment['runtime']['outputManager'] = outputManager.outputManager() environment['runtime']['outputManager'] = outputManager.outputManager()
environment['runtime']['outputManager'].initialize(environment) environment['runtime']['outputManager'].initialize(environment)
environment['runtime']['byteManager'] = byteManager.byteManager() environment['runtime']['byteManager'] = byteManager.byteManager()
environment['runtime']['byteManager'].initialize(environment) environment['runtime']['byteManager'].initialize(environment)
environment['runtime']['inputManager'] = inputManager.inputManager() environment['runtime']['inputManager'] = inputManager.inputManager()
environment['runtime']['inputManager'].initialize(environment) environment['runtime']['inputManager'].initialize(environment)
environment['runtime']['screenManager'] = screenManager.screenManager() environment['runtime']['screenManager'] = screenManager.screenManager()
environment['runtime']['screenManager'].initialize(environment) environment['runtime']['screenManager'].initialize(environment)
environment['runtime']['commandManager'] = commandManager.commandManager() environment['runtime']['commandManager'] = commandManager.commandManager()
environment['runtime']['commandManager'].initialize(environment) environment['runtime']['commandManager'].initialize(environment)
environment['runtime']['helpManager'] = helpManager.helpManager() environment['runtime']['helpManager'] = helpManager.helpManager()
environment['runtime']['helpManager'].initialize(environment) environment['runtime']['helpManager'].initialize(environment)
environment['runtime']['remoteManager'] = remoteManager.remoteManager()
environment['runtime']['remoteManager'].initialize(environment)
if environment['runtime']['inputManager'].getShortcutType() == 'KEY': if environment['runtime']['inputManager'].getShortcutType() == 'KEY':
if not os.path.exists(self.getSetting('keyboard','keyboardLayout')): if not os.path.exists(self.getSetting('keyboard','keyboardLayout')):

View File

@ -93,10 +93,10 @@ class driver(inputDriver):
event = None event = None
foundKeyInSequence = False foundKeyInSequence = False
foreward = False foreward = False
eventFired = False eventFired = False
for fd in r: for fd in r:
try: try:
event = self.iDevices[fd].read_one() event = self.iDevices[fd].read_one()
except: except:
self.removeDevice(fd) self.removeDevice(fd)
while(event): while(event):
@ -108,8 +108,10 @@ class driver(inputDriver):
if event.code != 0: if event.code != 0:
currMapEvent = self.mapEvent(event) currMapEvent = self.mapEvent(event)
if not currMapEvent: if not currMapEvent:
event = self.iDevices[fd].read_one()
continue continue
if not isinstance(currMapEvent['EventName'], str): if not isinstance(currMapEvent['EventName'], str):
event = self.iDevices[fd].read_one()
continue continue
if currMapEvent['EventState'] in [0,1,2]: if currMapEvent['EventState'] in [0,1,2]:
eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()}) eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()})
@ -118,7 +120,7 @@ class driver(inputDriver):
if event.type in [2,3]: if event.type in [2,3]:
foreward = True foreward = True
event = self.iDevices[fd].read_one() event = self.iDevices[fd].read_one()
if not foundKeyInSequence: if not foundKeyInSequence:
if foreward and not eventFired: if foreward and not eventFired:
self.writeEventBuffer() self.writeEventBuffer()

View File

@ -155,7 +155,8 @@ class driver(screenDriver):
"Data":self.createScreenEventData(currScreen,screenContent) "Data":self.createScreenEventData(currScreen,screenContent)
}) })
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR)
time.sleep(0.2)
def createScreenEventData(self, screen, content): def createScreenEventData(self, screen, content):