add setting save

This commit is contained in:
chrys 2018-09-08 22:23:27 +02:00
parent a0beb42e89
commit a97c31577a
2 changed files with 29 additions and 0 deletions

View File

@ -43,6 +43,7 @@ class remoteManager():
# setting controll
self.settingConst = 'SETTING '
self.setSettingConst = 'SET '
self.saveSettingConst = 'SAVE '
self.resetSettingConst = 'RESET'
def initialize(self, environment):
self.env = environment
@ -132,6 +133,10 @@ class remoteManager():
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()
@ -173,9 +178,19 @@ class remoteManager():
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):

View File

@ -78,7 +78,21 @@ 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('/tmp/settings.conf', 'w')
self.env['settings'].write(configFile)
except Exception as e:
print(e)
def setSetting(self, section, setting, value):
self.setOptionArgDict(section, setting, value)
#self.env['settings'].set(section, setting, value)