Better noPySide/noGUI/noPath handling

This commit is contained in:
Et0h 2014-06-30 01:27:04 +01:00
parent 88e7de39b7
commit f8af9ce927

View File

@ -93,7 +93,9 @@ class ConfigurationGetter(object):
self._config[key] = False self._config[key] = False
for key in self._required: for key in self._required:
if(key == "playerPath"): 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): if(player):
self._config["playerClass"] = player self._config["playerClass"] = player
else: else:
@ -193,7 +195,9 @@ class ConfigurationGetter(object):
sys.exit() sys.exit()
def _promptForMissingArguments(self, error=None): 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") print getMessage("en", "missing-arguments-error")
sys.exit() sys.exit()
elif(GuiConfiguration): elif(GuiConfiguration):
@ -228,17 +232,24 @@ class ConfigurationGetter(object):
def _forceGuiPrompt(self): def _forceGuiPrompt(self):
try: if GuiConfiguration:
self._validateArguments() try:
except InvalidConfigValue: self._validateArguments()
pass except InvalidConfigValue:
try: pass
if(self._config['noGui'] == False):
for key, value in self._promptForMissingArguments().items():
self._config[key] = value
except GuiConfiguration.WindowClosed:
sys.exit()
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): def __getRelativeConfigLocations(self):
locations = [] locations = []
@ -293,7 +304,7 @@ class ConfigurationGetter(object):
# Arguments not validated yet - booleans are still text values # Arguments not validated yet - booleans are still text values
if self._config['language']: if self._config['language']:
setLanguage(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._forceGuiPrompt()
self._checkConfig() self._checkConfig()
self._saveConfig(iniPath) self._saveConfig(iniPath)
@ -301,6 +312,8 @@ class ConfigurationGetter(object):
self._config['loadedRelativePaths'] = self._loadRelativeConfiguration() self._config['loadedRelativePaths'] = self._loadRelativeConfiguration()
if self._config['language']: if self._config['language']:
setLanguage(self._config['language']) setLanguage(self._config['language'])
if not GuiConfiguration:
self._config['noGui'] = True
if(not self._config['noGui']): if(not self._config['noGui']):
from syncplay.vendor import qt4reactor from syncplay.vendor import qt4reactor
if QCoreApplication.instance() is None: if QCoreApplication.instance() is None: