summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2019-06-14 16:11:37 +0530
committerAravinda VK <avishwan@redhat.com>2019-06-14 11:35:43 +0000
commit65e3624091e895ca32cd91468552589f34d17595 (patch)
treed4d3140b8cf1110fdf3cd1e8954c17ae9e07b8fc /extras
parent6eaa561526c340c48b12f0cf149c6c5a2903d751 (diff)
eventsapi: Fix Exception class for Python3
Python2 exception provides message attribute for custom exceptions. But it is not available in Python3. Add init method for custom exception to handle the same. Original crash(IndexError reported in the bug) was fixed with https://review.gluster.org/#/c/glusterfs/+/22294/ But that patch only works in Python2 and fails in Python3 since Exception in Python 3 doesn't have "message" attribute. Fixes: bz#1573226 Change-Id: If9117048f9ff0615f5da1880075ec12c0ff4855e Signed-off-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/cliutils/cliutils.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/extras/cliutils/cliutils.py b/extras/cliutils/cliutils.py
index 0095586827d..55fbaf56704 100644
--- a/extras/cliutils/cliutils.py
+++ b/extras/cliutils/cliutils.py
@@ -20,7 +20,14 @@ _common_args_func = lambda p: True
class GlusterCmdException(Exception):
- pass
+ def __init__(self, message):
+ self.message = message
+ try:
+ # Python 3
+ super().__init__(message)
+ except TypeError:
+ # Python 2
+ super(GlusterCmdException, self).__init__(message)
def get_node_uuid():