From 07f0a4a426517b678e6b704b007f00827da6772d Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 30 Nov 2014 14:35:18 +0000 Subject: [PATCH] Move InvalidConfigValue errors into messages.py --- syncplay/messages.py | 6 ++++++ syncplay/ui/ConfigurationGetter.py | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/syncplay/messages.py b/syncplay/messages.py index e81d5b2..e111f93 100755 --- a/syncplay/messages.py +++ b/syncplay/messages.py @@ -92,6 +92,12 @@ en = { "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", "hello-arguments-error" : "Not enough Hello arguments\n", "version-mismatch-error" : "Mismatch between versions of client and server\n", diff --git a/syncplay/ui/ConfigurationGetter.py b/syncplay/ui/ConfigurationGetter.py index 37d18f4..610646a 100755 --- a/syncplay/ui/ConfigurationGetter.py +++ b/syncplay/ui/ConfigurationGetter.py @@ -144,20 +144,20 @@ class ConfigurationGetter(object): if player: self._config["playerClass"] = player else: - raise InvalidConfigValue("Player path is not set properly") + raise InvalidConfigValue(getMessage("player-path-config-error")) if player.__name__ in ['MpvPlayer', 'MplayerPlayer']: 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": self._config["host"], self._config["port"] = self._splitPortAndHost(self._config["host"]) hostNotValid = (self._config["host"] == "" or self._config["host"] is None) portNotValid = (_isPortValid(self._config["port"]) == False) if hostNotValid: - raise InvalidConfigValue("Hostname can't be empty") + raise InvalidConfigValue(getMessage("no-hostname-config-error")) 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: - raise InvalidConfigValue("{} can't be empty".format(key.capitalize())) + raise InvalidConfigValue(getMessage("empty-value-config-error").format(key.capitalize())) def _overrideConfigWithArgs(self, args): for key, val in vars(args).items(): @@ -386,4 +386,4 @@ class SafeConfigParserUnicode(SafeConfigParser): if (value is not None) or (self._optcre == self.OPTCRE): key = " = ".join((key, unicode(value).replace('\n', '\n\t'))) fp.write("%s\n" % key) - fp.write("\n") + fp.write("\n") \ No newline at end of file