From f8af9ce927034afa95f9fc88731af6ecbdb4632c Mon Sep 17 00:00:00 2001 From: Et0h Date: Mon, 30 Jun 2014 01:27:04 +0100 Subject: [PATCH] Better noPySide/noGUI/noPath handling --- syncplay/ui/ConfigurationGetter.py | 39 ++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index 9183199..b1ad9fc 100644 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -93,7 +93,9 @@ class ConfigurationGetter(object): self._config[key] = False for key in self._required: if(key == "playerPath"): - player = self._playerFactory.getPlayerByPath(self._config["playerPath"]) + player = None + if self._config["playerPath"]: + player = self._playerFactory.getPlayerByPath(self._config["playerPath"]) if(player): self._config["playerClass"] = player else: @@ -193,7 +195,9 @@ class ConfigurationGetter(object): sys.exit() def _promptForMissingArguments(self, error=None): - if(self._config['noGui']): + if(self._config['noGui'] or not GuiConfiguration): + if error: + print "{}!".format(error) print getMessage("en", "missing-arguments-error") sys.exit() elif(GuiConfiguration): @@ -228,17 +232,24 @@ class ConfigurationGetter(object): def _forceGuiPrompt(self): - try: - self._validateArguments() - except InvalidConfigValue: - pass - try: - if(self._config['noGui'] == False): - for key, value in self._promptForMissingArguments().items(): - self._config[key] = value - except GuiConfiguration.WindowClosed: - sys.exit() + if GuiConfiguration: + try: + self._validateArguments() + except InvalidConfigValue: + pass + try: + if(self._config['noGui'] == False): + for key, value in self._promptForMissingArguments().items(): + self._config[key] = value + except GuiConfiguration.WindowClosed: + sys.exit() + else: + try: + self._validateArguments() + except InvalidConfigValue: + self._promptForMissingArguments() + sys.exit() def __getRelativeConfigLocations(self): locations = [] @@ -293,7 +304,7 @@ class ConfigurationGetter(object): # Arguments not validated yet - booleans are still text values if self._config['language']: setLanguage(self._config['language']) - if(self._config['forceGuiPrompt'] == "True" or not self._config['file']): + if((self._config['forceGuiPrompt'] == "True" or not self._config['file']) and GuiConfiguration and not self._config['noGui']): self._forceGuiPrompt() self._checkConfig() self._saveConfig(iniPath) @@ -301,6 +312,8 @@ class ConfigurationGetter(object): self._config['loadedRelativePaths'] = self._loadRelativeConfiguration() if self._config['language']: setLanguage(self._config['language']) + if not GuiConfiguration: + self._config['noGui'] = True if(not self._config['noGui']): from syncplay.vendor import qt4reactor if QCoreApplication.instance() is None: