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
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: