Update settingsManager.py

This commit is contained in:
chrys87 2016-09-15 10:10:01 +02:00 committed by GitHub
parent 82757b7a93
commit 14125c7ccc

View File

@ -31,7 +31,10 @@ class settingsManager():
continue continue
sepLine = line.split('=') sepLine = line.split('=')
commandName = sepLine[1] commandName = sepLine[1]
keys = sepLine[0].replace(" ","").replace("'","").replace('"',"").split(',') sepLine[0] = sepLine[0].replace(" ","")
sepLine[0] = sepLine[0].replace("'","")
sepLine[0] = sepLine[0].replace('"',"")
keys = sepLine[0]..split(',')
shortcutKeys = [] shortcutKeys = []
shortcutRepeat = 1 shortcutRepeat = 1
shortcut = [] shortcut = []
@ -39,7 +42,7 @@ class settingsManager():
try: try:
shortcutRepeat = int(key) shortcutRepeat = int(key)
except: except:
shortcutKeys.append(key) shortcutKeys.append(key.upper())
shortcut.append(shortcutRepeat) shortcut.append(shortcutRepeat)
shortcut.append(sorted(shortcutKeys)) shortcut.append(sorted(shortcutKeys))
print(str(shortcut)) print(str(shortcut))
@ -53,7 +56,7 @@ class settingsManager():
except: except:
return 0 return 0
def loadSoundIcons(self, environment, soundIconPath=''): def loadSoundIcons(self, environment, soundIconPath):
siConfig = open(soundIconPath + '/soundicons.conf',"r") siConfig = open(soundIconPath + '/soundicons.conf',"r")
while(True): while(True):
line = siConfig.readline() line = siConfig.readline()
@ -65,8 +68,6 @@ class settingsManager():
if line.count("=") != 1: if line.count("=") != 1:
continue continue
Values = line.split('=') Values = line.split('=')
if len(Values) > 2:
continue
soundIcon = Values[0] soundIcon = Values[0]
Values[1] = Values[1].replace("'","") Values[1] = Values[1].replace("'","")
Values[1] = Values[1].replace('"',"") Values[1] = Values[1].replace('"',"")
@ -74,14 +75,11 @@ class settingsManager():
FilePath = '' FilePath = ''
if os.path.exists(Values[1]): if os.path.exists(Values[1]):
FilePath = Values[1] FilePath = Values[1]
validSoundIcon = True
else: else:
if not soundIconPath.endswith("/"): if not soundIconPath.endswith("/"):
soundIconPath += '/' soundIconPath += '/'
if os.path.exists(soundIconPath + Values[1]): if os.path.exists(soundIconPath + Values[1]):
FilePath = soundIconPath + Values[1] FilePath = soundIconPath + Values[1]
validSoundIcon = True
if validSoundIcon:
environment['soundIcons'][soundIcon] = FilePath environment['soundIcons'][soundIcon] = FilePath
siConfig.close() siConfig.close()
return environment return environment
@ -156,12 +154,13 @@ class settingsManager():
return '' return ''
def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/', settingsFile='settings.conf'): def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/', settingsFile='settings.conf'):
environment['runtime']['debug'] = debug.debug()
if not os.path.exists(settingsRoot): if not os.path.exists(settingsRoot):
if os.path.exists('../../config/'): if os.path.exists('../../config/'):
settingsRoot = '../../config/' settingsRoot = '../../config/'
else: else:
return None return None
environment['runtime']['debug'] = debug.debug()
environment['runtime']['settingsManager'] = self environment['runtime']['settingsManager'] = self
environment = environment['runtime']['settingsManager'].loadSettings(environment, settingsRoot + '/settings/' + settingsFile) environment = environment['runtime']['settingsManager'].loadSettings(environment, settingsRoot + '/settings/' + settingsFile)
if environment == None: if environment == None: