[PATCH] [Wok] Issue #190: No activity logging is shown and its break if any one entry in activity log does not have proper key

From: Archana Singh <archus@linux.vnet.ibm.com> Currently activity logs breaks in UI, if an error code is changed with additional parameter. For example an error code does not have any parameter and its logged in user-requests.data with params as empty. And however same error code is changed to have a parameter, and hence while parsing activity log it is expected to have parameter in params. Due to which parsing fails with KeyError. This fix handle the KeyError and in case of KeyError the error message will be shown without replacing the parameter with its value. Signed-off-by: Archana Singh <archus@linux.vnet.ibm.com> --- src/wok/message.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wok/message.py b/src/wok/message.py index ff4cbc9..460d90d 100644 --- a/src/wok/message.py +++ b/src/wok/message.py @@ -86,7 +86,10 @@ class WokMessage(object): def get_text(self, prepend_code=True, translate=True): msg = self._get_text(translate) - msg = decode_value(msg) % self.args + try: + msg = decode_value(msg) % self.args + except KeyError: + msg = decode_value(msg) if prepend_code: return "%s: %s" % (self.code, msg) -- 2.7.4

This is useful to make development more efficient, to not be blocked on that kind of issues. On the other hand it will hide messages that need fix on parameter improvements, but as a development tool it will allow to find those messages. In summary, this patch has more benefits. Reviewed-By: Lucio Correia <luciojhc@linux.vnet.ibm.com> On 08/12/2016 08:19, archus@linux.vnet.ibm.com wrote:
From: Archana Singh <archus@linux.vnet.ibm.com>
Currently activity logs breaks in UI, if an error code is changed with additional parameter. For example an error code does not have any parameter and its logged in user-requests.data with params as empty. And however same error code is changed to have a parameter, and hence while parsing activity log it is expected to have parameter in params. Due to which parsing fails with KeyError. This fix handle the KeyError and in case of KeyError the error message will be shown without replacing the parameter with its value.
Signed-off-by: Archana Singh <archus@linux.vnet.ibm.com> --- src/wok/message.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/wok/message.py b/src/wok/message.py index ff4cbc9..460d90d 100644 --- a/src/wok/message.py +++ b/src/wok/message.py @@ -86,7 +86,10 @@ class WokMessage(object):
def get_text(self, prepend_code=True, translate=True): msg = self._get_text(translate) - msg = decode_value(msg) % self.args + try: + msg = decode_value(msg) % self.args + except KeyError: + msg = decode_value(msg)
if prepend_code: return "%s: %s" % (self.code, msg)
-- Lucio Correia Software Engineer IBM LTC Brazil

On 12/08/2016 08:19 AM, archus@linux.vnet.ibm.com wrote:
From: Archana Singh <archus@linux.vnet.ibm.com>
Currently activity logs breaks in UI, if an error code is changed with additional parameter. For example an error code does not have any parameter and its logged in user-requests.data with params as empty. And however same error code is changed to have a parameter, and hence while parsing activity log it is expected to have parameter in params. Due to which parsing fails with KeyError. This fix handle the KeyError and in case of KeyError the error message will be shown without replacing the parameter with its value.
Signed-off-by: Archana Singh <archus@linux.vnet.ibm.com> --- src/wok/message.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/wok/message.py b/src/wok/message.py index ff4cbc9..460d90d 100644 --- a/src/wok/message.py +++ b/src/wok/message.py @@ -86,7 +86,10 @@ class WokMessage(object):
def get_text(self, prepend_code=True, translate=True): msg = self._get_text(translate) - msg = decode_value(msg) % self.args + try:
+ msg = decode_value(msg) % self.args + except KeyError: + msg = decode_value(msg)
It would be good to print the args as well to make easier identify the problem except KeyError: msg = decode_value(msg) + " " + str(self.args)
if prepend_code: return "%s: %s" % (self.code, msg)
participants (3)
-
Aline Manera
-
archus@linux.vnet.ibm.com
-
Lucio Correia