Move InvalidConfigValue errors into messages.py

This commit is contained in:
Et0h 2014-11-30 14:35:18 +00:00
parent dbb0ff067f
commit 07f0a4a426
2 changed files with 12 additions and 6 deletions

View File

@ -92,6 +92,12 @@ en = {
"unable-to-start-client-error" : "Unable to start client", "unable-to-start-client-error" : "Unable to start client",
"player-path-config-error": "Player path is not set properly",
"no-file-path-config-error" :"File must be selected before starting your player",
"no-hostname-config-error": "Hostname can't be empty",
"invalid-port-config-error" : "Port must be valid",
"empty-value-config-error" : "{} can't be empty", # Config option
"not-json-error" : "Not a json encoded string\n", "not-json-error" : "Not a json encoded string\n",
"hello-arguments-error" : "Not enough Hello arguments\n", "hello-arguments-error" : "Not enough Hello arguments\n",
"version-mismatch-error" : "Mismatch between versions of client and server\n", "version-mismatch-error" : "Mismatch between versions of client and server\n",

View File

@ -144,20 +144,20 @@ class ConfigurationGetter(object):
if player: if player:
self._config["playerClass"] = player self._config["playerClass"] = player
else: else:
raise InvalidConfigValue("Player path is not set properly") raise InvalidConfigValue(getMessage("player-path-config-error"))
if player.__name__ in ['MpvPlayer', 'MplayerPlayer']: if player.__name__ in ['MpvPlayer', 'MplayerPlayer']:
if not self._config['file']: if not self._config['file']:
raise InvalidConfigValue("File must be selected before starting your player") raise InvalidConfigValue(getMessage("no-file-path-config-error"))
elif key == "host": elif key == "host":
self._config["host"], self._config["port"] = self._splitPortAndHost(self._config["host"]) self._config["host"], self._config["port"] = self._splitPortAndHost(self._config["host"])
hostNotValid = (self._config["host"] == "" or self._config["host"] is None) hostNotValid = (self._config["host"] == "" or self._config["host"] is None)
portNotValid = (_isPortValid(self._config["port"]) == False) portNotValid = (_isPortValid(self._config["port"]) == False)
if hostNotValid: if hostNotValid:
raise InvalidConfigValue("Hostname can't be empty") raise InvalidConfigValue(getMessage("no-hostname-config-error"))
elif portNotValid: elif portNotValid:
raise InvalidConfigValue("Port must be valid") raise InvalidConfigValue(getMessage("invalid-port-config-error"))
elif self._config[key] == "" or self._config[key] is None: elif self._config[key] == "" or self._config[key] is None:
raise InvalidConfigValue("{} can't be empty".format(key.capitalize())) raise InvalidConfigValue(getMessage("empty-value-config-error").format(key.capitalize()))
def _overrideConfigWithArgs(self, args): def _overrideConfigWithArgs(self, args):
for key, val in vars(args).items(): for key, val in vars(args).items():