mirror of
https://github.com/Syncplay/syncplay
synced 2025-03-11 06:07:53 +00:00
Some fixes with configuration processing
This commit is contained in:
parent
98fac4ac0f
commit
9013c79a9a
@ -44,10 +44,18 @@ class ConfigurationGetter(object):
|
||||
"playerPath",
|
||||
"playerClass",
|
||||
]
|
||||
|
||||
self._boolean = [
|
||||
"debug",
|
||||
"forceGuiPrompt",
|
||||
"noGui",
|
||||
"noStore",
|
||||
"slowOnDesync"
|
||||
]
|
||||
|
||||
self._iniStructure = {
|
||||
"server_data": ["host", "port", "password"],
|
||||
"client_settings": ["name", "room", "playerPath"]
|
||||
"client_settings": ["name", "room", "playerPath", "slowOnDesync", "forceGuiPrompt"]
|
||||
}
|
||||
|
||||
#
|
||||
@ -67,10 +75,14 @@ class ConfigurationGetter(object):
|
||||
self._argparser.add_argument('file', metavar='file', type=str, nargs='?', help=getMessage("en", "file-argument"))
|
||||
self._argparser.add_argument('_args', metavar='options', type=str, nargs='*', help=getMessage("en", "args-argument"))
|
||||
|
||||
|
||||
self._playerFactory = PlayerFactory()
|
||||
|
||||
def _validateArguments(self):
|
||||
for key in self._boolean:
|
||||
if(self._config[key] == "True"):
|
||||
self._config[key] = True
|
||||
elif(self._config[key] == "False"):
|
||||
self._config[key] = False
|
||||
for key in self._required:
|
||||
if(key == "playerPath"):
|
||||
player = self._playerFactory.getPlayerByPath(self._config["playerPath"])
|
||||
@ -86,7 +98,7 @@ class ConfigurationGetter(object):
|
||||
raise InvalidConfigValue("Hostname can't be empty")
|
||||
elif(self._config[key] == "" or self._config[key] is None):
|
||||
raise InvalidConfigValue("{} can't be empty".format(key))
|
||||
|
||||
|
||||
def _overrideConfigWithArgs(self, args):
|
||||
for key, val in vars(args).items():
|
||||
if(val):
|
||||
@ -186,6 +198,11 @@ class ConfigurationGetter(object):
|
||||
self._overrideConfigWithArgs(args)
|
||||
if(self._config['forceGuiPrompt']):
|
||||
try:
|
||||
self._validateArguments()
|
||||
except InvalidConfigValue:
|
||||
pass
|
||||
try:
|
||||
print self._config
|
||||
self._promptForMissingArguments()
|
||||
except:
|
||||
sys.exit()
|
||||
|
@ -71,13 +71,13 @@ class GuiConfiguration:
|
||||
self.config['password'] = self.passEntry.get_text()
|
||||
self.config['playerPath'] = self.mpcEntry.get_text()
|
||||
if self.alwaysShowCheck.get_active() == True:
|
||||
self.config['noGui'] = True
|
||||
self.config['forceGuiPrompt'] = True
|
||||
else:
|
||||
self.config['noGui'] = False
|
||||
self.config['forceGuiPrompt'] = False
|
||||
if self.storeConfigCheck.get_active() == True:
|
||||
self.config['noStore'] = True
|
||||
else:
|
||||
self.config['noStore'] = False
|
||||
self.config['noStore'] = False
|
||||
if self.slowOnDesyncCheck.get_active() == True:
|
||||
self.config['slowOnDesync'] = True
|
||||
else:
|
||||
@ -109,8 +109,8 @@ class GuiConfiguration:
|
||||
CheckVbox = gtk.VBox(False, 0)
|
||||
vbox.pack_start(CheckVbox, False, False, 0)
|
||||
self.alwaysShowCheck = gtk.CheckButton("Always Show This Dialog")
|
||||
if self.config['noGui'] == True:
|
||||
self.alwaysShowCheck.set_active(True)
|
||||
if self.config['forceGuiPrompt'] == True:
|
||||
self.alwaysShowCheck.set_active(True)
|
||||
self.alwaysShowCheck.show()
|
||||
self.storeConfigCheck = gtk.CheckButton("Do Not Store This Configuration")
|
||||
if self.config['noStore'] == True:
|
||||
|
Loading…
Reference in New Issue
Block a user