Merge branch 'remotesetting'
This commit is contained in:
commit
79b4ac32fb
@ -122,7 +122,6 @@ driver=vcsaDriver
|
||||
encoding=auto
|
||||
screenUpdateDelay=0.05
|
||||
suspendingScreen=
|
||||
suspendingScreenFile=/tmp/fenrirSuspend
|
||||
autodetectSuspendingScreen=True
|
||||
|
||||
[keyboard]
|
||||
@ -187,6 +186,21 @@ shell=
|
||||
cursor=True
|
||||
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]
|
||||
enabled=True
|
||||
leftBarriers=│└┌─
|
||||
|
@ -124,7 +124,6 @@ driver=vcsaDriver
|
||||
encoding=auto
|
||||
screenUpdateDelay=0.05
|
||||
suspendingScreen=
|
||||
suspendingScreenFile=/tmp/fenrirSuspend
|
||||
autodetectSuspendingScreen=True
|
||||
|
||||
[keyboard]
|
||||
@ -197,6 +196,21 @@ cursor=True
|
||||
#follow highlighted text changes
|
||||
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]
|
||||
enabled=True
|
||||
leftBarriers=│└┌─
|
||||
|
@ -125,7 +125,6 @@ driver=vcsaDriver
|
||||
encoding=auto
|
||||
screenUpdateDelay=0.05
|
||||
suspendingScreen=
|
||||
suspendingScreenFile=/tmp/fenrirSuspend
|
||||
autodetectSuspendingScreen=True
|
||||
|
||||
[keyboard]
|
||||
@ -198,6 +197,21 @@ cursor=True
|
||||
#follow highlighted text changes
|
||||
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]
|
||||
enabled=True
|
||||
leftBarriers=│└┌─
|
||||
|
@ -79,7 +79,6 @@ driver=vcsaDriver
|
||||
encoding=auto
|
||||
screenUpdateDelay=0.05
|
||||
suspendingScreen=
|
||||
suspendingScreenFile=/tmp/fenrirSuspend
|
||||
autodetectSuspendingScreen=True
|
||||
|
||||
[keyboard]
|
||||
@ -143,6 +142,21 @@ cursor=True
|
||||
#follow highlighted text changes
|
||||
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]
|
||||
enabled=True
|
||||
leftBarriers=│└┌─
|
||||
|
@ -124,7 +124,6 @@ driver=vcsaDriver
|
||||
encoding=auto
|
||||
screenUpdateDelay=0.05
|
||||
suspendingScreen=
|
||||
suspendingScreenFile=/tmp/fenrirSuspend
|
||||
autodetectSuspendingScreen=True
|
||||
|
||||
[keyboard]
|
||||
@ -197,6 +196,21 @@ cursor=True
|
||||
#follow highlighted text changes
|
||||
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]
|
||||
enabled=True
|
||||
leftBarriers=│└┌─
|
||||
|
13
realese nots/1.9.3
Normal file
13
realese nots/1.9.3
Normal 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
|
@ -35,17 +35,17 @@ class byteManager():
|
||||
if eventData == b'':
|
||||
return
|
||||
|
||||
convertedEscapeSequence = self.unifyEscapeSeq(eventData)
|
||||
convertedEscapeSequence = self.unifyEscapeSeq(eventData)
|
||||
|
||||
if self.switchCtrlModeOnce > 0:
|
||||
self.switchCtrlModeOnce -= 1
|
||||
|
||||
self.switchCtrlModeOnce -= 1
|
||||
|
||||
isControlMode = False
|
||||
if self.controlMode and not self.switchCtrlModeOnce == 1 or\
|
||||
not self.controlMode:
|
||||
isControlMode = self.handleControlMode(eventData)
|
||||
|
||||
isCommand = False
|
||||
isCommand = False
|
||||
if self.controlMode and not self.switchCtrlModeOnce == 1 or\
|
||||
not self.controlMode and self.switchCtrlModeOnce == 1:
|
||||
if self.lastByteKey == convertedEscapeSequence:
|
||||
@ -53,16 +53,16 @@ class byteManager():
|
||||
self.repeat += 1
|
||||
shortcutData = b''
|
||||
for i in range(self.repeat):
|
||||
shortcutData = shortcutData + convertedEscapeSequence
|
||||
shortcutData = shortcutData + convertedEscapeSequence
|
||||
isCommand = self.detectByteCommand(shortcutData)
|
||||
# fall back to single stroke - do we want this?
|
||||
if not isCommand:
|
||||
isCommand = self.detectByteCommand(convertedEscapeSequence)
|
||||
self.repeat = 1
|
||||
self.repeat = 1
|
||||
if not (isCommand or isControlMode):
|
||||
self.env['runtime']['screenManager'].injectTextToScreen(eventData)
|
||||
if not isCommand:
|
||||
self.repeat = 1
|
||||
self.repeat = 1
|
||||
self.lastByteKey = convertedEscapeSequence
|
||||
self.lastInputTime = time.time()
|
||||
def getLastByteKey(self):
|
||||
|
@ -82,21 +82,40 @@ class cursorManager():
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
def setWindowForApplication(self):
|
||||
if not self.env['commandBuffer']['Marks']['1']:
|
||||
return False
|
||||
if not self.env['commandBuffer']['Marks']['2']:
|
||||
return False
|
||||
def setWindowForApplication(self, start = None, end = None):
|
||||
x1 = 0
|
||||
x2 = 0
|
||||
y1 = 0
|
||||
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()
|
||||
self.env['commandBuffer']['windowArea'][currApp] = {}
|
||||
|
||||
if self.env['commandBuffer']['Marks']['1']['x'] * self.env['commandBuffer']['Marks']['1']['y'] <= \
|
||||
self.env['commandBuffer']['Marks']['2']['x'] * self.env['commandBuffer']['Marks']['2']['y']:
|
||||
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy()
|
||||
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy()
|
||||
if x1 * y1 <= \
|
||||
x2 * y2:
|
||||
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x1, 'y':y1}
|
||||
self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x2, 'y':y2}
|
||||
else:
|
||||
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['2'].copy()
|
||||
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['1'].copy()
|
||||
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x2, 'y':y2}
|
||||
self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x1, 'y':y1}
|
||||
return True
|
||||
def clearWindowForApplication(self):
|
||||
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
|
||||
|
@ -18,7 +18,8 @@ class fenrirEventType(Enum):
|
||||
ScreenChanged = 7
|
||||
HeartBeat = 8 # for time based scheduling
|
||||
ExecuteCommand = 9
|
||||
ByteInput = 10
|
||||
ByteInput = 10
|
||||
RemoteIncomming = 11
|
||||
def __int__(self):
|
||||
return self.value
|
||||
def __str__(self):
|
||||
|
@ -29,7 +29,7 @@ class eventManager():
|
||||
#print('NET loop ' + str(time.time() - st))
|
||||
def eventDispatcher(self, event):
|
||||
self.env['runtime']['debug'].writeDebugOut('eventManager:eventDispatcher:start: event: ' + str(event['Type']),debug.debugLevel.INFO)
|
||||
|
||||
|
||||
if not event:
|
||||
return
|
||||
if not event['Type']:
|
||||
@ -55,7 +55,9 @@ class eventManager():
|
||||
elif event['Type'] == fenrirEventType.ExecuteCommand:
|
||||
self.env['runtime']['fenrirManager'].handleExecuteCommand(event)
|
||||
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):
|
||||
return self.running.value == 1
|
||||
def startMainEventLoop(self):
|
||||
@ -77,9 +79,9 @@ class eventManager():
|
||||
except Empty:
|
||||
pass
|
||||
def getEventQueue(self):
|
||||
return self._eventQueue
|
||||
return self._eventQueue
|
||||
def getRunning(self):
|
||||
return self.running
|
||||
return self.running
|
||||
def putToEventQueue(self,event, data):
|
||||
if not isinstance(event, fenrirEventType):
|
||||
return False
|
||||
|
@ -105,6 +105,10 @@ class fenrirManager():
|
||||
self.environment['runtime']['commandManager'].executeCommand( command, 'help')
|
||||
return
|
||||
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):
|
||||
self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data'])
|
||||
'''
|
||||
|
208
src/fenrirscreenreader/core/remoteManager.py
Normal file
208
src/fenrirscreenreader/core/remoteManager.py
Normal 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)
|
@ -195,15 +195,7 @@ class screenManager():
|
||||
if fixIgnoreScreens != '':
|
||||
ignoreScreens.extend(fixIgnoreScreens.split(','))
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'):
|
||||
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
|
||||
ignoreScreens.extend(self.env['screen']['autoIgnoreScreens'])
|
||||
self.env['runtime']['debug'].writeDebugOut('screenManager:isSuspendingScreen ignore:' + str(ignoreScreens) + ' current:'+ str(screen ), debug.debugLevel.INFO)
|
||||
return (screen in ignoreScreens)
|
||||
|
||||
@ -214,7 +206,7 @@ class screenManager():
|
||||
def isDelta(self, ignoreSpace=False):
|
||||
newDelta = self.env['screen']['newDelta']
|
||||
if ignoreSpace:
|
||||
newDelta = newDelta.strip()
|
||||
newDelta = newDelta.strip()
|
||||
return newDelta != ''
|
||||
def isNegativeDelta(self):
|
||||
return self.env['screen']['newNegativeDelta'] != ''
|
||||
|
@ -51,7 +51,6 @@ settingsData = {
|
||||
'encoding': 'auto',
|
||||
'screenUpdateDelay': 0.1,
|
||||
'suspendingScreen': '',
|
||||
'suspendingScreenFile': '/tmp/fenrirSuspend',
|
||||
'autodetectSuspendingScreen': False,
|
||||
},
|
||||
'general':{
|
||||
@ -80,7 +79,14 @@ settingsData = {
|
||||
'focus':{
|
||||
'cursor': True,
|
||||
'highlight': False,
|
||||
|
||||
},
|
||||
'remote':{
|
||||
'enabled': True,
|
||||
'method': 'unix',
|
||||
'port': 22447,
|
||||
'socketpath':'/tmp/',
|
||||
'enableSettingsRemote': True,
|
||||
'enableCommandRemote': True,
|
||||
},
|
||||
'barrier':{
|
||||
'enabled': True,
|
||||
|
@ -5,6 +5,7 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
import os, inspect
|
||||
|
||||
currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe()))))
|
||||
fenrirPath = os.path.dirname(currentdir)
|
||||
|
||||
@ -26,6 +27,7 @@ from fenrirscreenreader.core import tableManager
|
||||
from fenrirscreenreader.core import byteManager
|
||||
from fenrirscreenreader.core import attributeManager
|
||||
from fenrirscreenreader.core import barrierManager
|
||||
from fenrirscreenreader.core import remoteManager
|
||||
from fenrirscreenreader.core import environment
|
||||
from fenrirscreenreader.core.settingsData import settingsData
|
||||
from fenrirscreenreader.core import debug
|
||||
@ -77,18 +79,35 @@ class settingsManager():
|
||||
self.env['settings'] = ConfigParser()
|
||||
self.env['settings'].read(settingConfigPath)
|
||||
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):
|
||||
self.env['settings'].set(section, setting, value)
|
||||
self.setOptionArgDict(section, setting, value)
|
||||
#self.env['settings'].set(section, setting, value)
|
||||
|
||||
def getSetting(self, section, setting):
|
||||
value = ''
|
||||
try:
|
||||
value = self.settingArgDict[section.lower()][setting.lower()]
|
||||
return value
|
||||
return value
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
try:
|
||||
value = self.env['settings'].get(section, setting)
|
||||
except:
|
||||
value = str(self.settings[section][setting])
|
||||
@ -98,7 +117,7 @@ class settingsManager():
|
||||
value = 0
|
||||
try:
|
||||
value = int(self.settingArgDict[section.lower()][setting.lower()])
|
||||
return value
|
||||
return value
|
||||
except Exception as e:
|
||||
pass
|
||||
try:
|
||||
@ -111,9 +130,9 @@ class settingsManager():
|
||||
value = 0.0
|
||||
try:
|
||||
value = float(self.settingArgDict[section.lower()][setting.lower()])
|
||||
return value
|
||||
return value
|
||||
except Exception as e:
|
||||
pass
|
||||
pass
|
||||
try:
|
||||
value = self.env['settings'].getfloat(section, setting)
|
||||
except:
|
||||
@ -158,8 +177,8 @@ class settingsManager():
|
||||
try:
|
||||
self.env['runtime'][driverType].shutdown()
|
||||
except Exception as e:
|
||||
pass
|
||||
del self.env['runtime'][driverType]
|
||||
pass
|
||||
del self.env['runtime'][driverType]
|
||||
|
||||
def setFenrirKeys(self, keys):
|
||||
keys = keys.upper()
|
||||
@ -173,6 +192,8 @@ class settingsManager():
|
||||
for key in keyList:
|
||||
if not key in self.env['input']['scriptKey']:
|
||||
self.env['input']['scriptKey'].append(key)
|
||||
def resetSettingArgDict(self):
|
||||
self.settingArgDict = {}
|
||||
def setOptionArgDict(self, section, option, value):
|
||||
section = section.lower()
|
||||
option = option.lower()
|
||||
@ -180,17 +201,18 @@ class settingsManager():
|
||||
e = self.settingArgDict[section]
|
||||
except KeyError:
|
||||
self.settingArgDict[section] = {}
|
||||
self.settingArgDict[section][option] = str(value)
|
||||
|
||||
self.settingArgDict[section][option] = str(value)
|
||||
|
||||
def parseSettingArgs(self, settingArgs):
|
||||
for optionElem in settingArgs.split(';'):
|
||||
if len(optionElem.split('#',1)) != 2:
|
||||
continue
|
||||
if len(optionElem.split('#',1)[1].split('=',1)) != 2:
|
||||
continue
|
||||
|
||||
section = str(optionElem.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)
|
||||
|
||||
def initFenrirConfig(self, cliArgs, fenrirManager = None, environment = environment.environment):
|
||||
@ -208,7 +230,7 @@ class settingsManager():
|
||||
if os.path.exists(settingsRoot + '/settings/settings.conf'):
|
||||
settingsFile = settingsRoot + '/settings/settings.conf'
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
# get sound themes root
|
||||
if not os.path.exists(soundRoot):
|
||||
if os.path.exists(fenrirPath + '/../../config/sound/'):
|
||||
@ -234,12 +256,12 @@ class settingsManager():
|
||||
#self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty')
|
||||
self.setSetting('keyboard', 'keyboardLayout', 'pty')
|
||||
self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log')
|
||||
if cliArgs.emulated_evdev:
|
||||
self.setOptionArgDict('screen', 'driver', 'ptyDriver')
|
||||
self.setOptionArgDict('keyboard', 'driver', 'evdevDriver')
|
||||
if cliArgs.emulated_evdev:
|
||||
self.setOptionArgDict('screen', 'driver', 'ptyDriver')
|
||||
self.setOptionArgDict('keyboard', 'driver', 'evdevDriver')
|
||||
|
||||
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'].initialize(environment)
|
||||
@ -268,39 +290,43 @@ class settingsManager():
|
||||
else:
|
||||
environment['runtime']['punctuationManager'].loadDicts(self.getSetting('general','punctuationProfile'))
|
||||
|
||||
|
||||
|
||||
if fenrirManager:
|
||||
environment['runtime']['fenrirManager'] = fenrirManager
|
||||
|
||||
environment['runtime']['memoryManager'] = memoryManager.memoryManager()
|
||||
environment['runtime']['memoryManager'].initialize(environment)
|
||||
|
||||
|
||||
environment['runtime']['attributeManager'] = attributeManager.attributeManager()
|
||||
environment['runtime']['attributeManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['attributeManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['eventManager'] = eventManager.eventManager()
|
||||
environment['runtime']['eventManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['eventManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['processManager'] = processManager.processManager()
|
||||
environment['runtime']['processManager'].initialize(environment)
|
||||
environment['runtime']['processManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['outputManager'] = outputManager.outputManager()
|
||||
environment['runtime']['outputManager'].initialize(environment)
|
||||
environment['runtime']['outputManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['byteManager'] = byteManager.byteManager()
|
||||
environment['runtime']['byteManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['byteManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['inputManager'] = inputManager.inputManager()
|
||||
environment['runtime']['inputManager'].initialize(environment)
|
||||
environment['runtime']['inputManager'].initialize(environment)
|
||||
|
||||
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']['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 not os.path.exists(self.getSetting('keyboard','keyboardLayout')):
|
||||
|
@ -93,10 +93,10 @@ class driver(inputDriver):
|
||||
event = None
|
||||
foundKeyInSequence = False
|
||||
foreward = False
|
||||
eventFired = False
|
||||
for fd in r:
|
||||
eventFired = False
|
||||
for fd in r:
|
||||
try:
|
||||
event = self.iDevices[fd].read_one()
|
||||
event = self.iDevices[fd].read_one()
|
||||
except:
|
||||
self.removeDevice(fd)
|
||||
while(event):
|
||||
@ -108,8 +108,10 @@ class driver(inputDriver):
|
||||
if event.code != 0:
|
||||
currMapEvent = self.mapEvent(event)
|
||||
if not currMapEvent:
|
||||
event = self.iDevices[fd].read_one()
|
||||
continue
|
||||
if not isinstance(currMapEvent['EventName'], str):
|
||||
event = self.iDevices[fd].read_one()
|
||||
continue
|
||||
if currMapEvent['EventState'] in [0,1,2]:
|
||||
eventQueue.put({"Type":fenrirEventType.KeyboardInput,"Data":currMapEvent.copy()})
|
||||
@ -118,7 +120,7 @@ class driver(inputDriver):
|
||||
if event.type in [2,3]:
|
||||
foreward = True
|
||||
|
||||
event = self.iDevices[fd].read_one()
|
||||
event = self.iDevices[fd].read_one()
|
||||
if not foundKeyInSequence:
|
||||
if foreward and not eventFired:
|
||||
self.writeEventBuffer()
|
||||
|
@ -155,7 +155,8 @@ class driver(screenDriver):
|
||||
"Data":self.createScreenEventData(currScreen,screenContent)
|
||||
})
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user