aboutsummaryrefslogtreecommitdiffstats
path: root/calls.py
diff options
context:
space:
mode:
Diffstat (limited to 'calls.py')
-rw-r--r--calls.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/calls.py b/calls.py
index 8c615b8..d4c8f2c 100644
--- a/calls.py
+++ b/calls.py
@@ -14,16 +14,26 @@ class EjabberdApiCalls(EjabberdApi):
@property
def nodename(self):
if self._login is not None:
- node_str = re.compile("The node '(.*)'")
status = self.cmd("status", {})
+ # "The node ejabberd@localhost is started with status: startedejabberd 20.07 is running in that node"
- # matches
try:
- tmp = node_str.findall(status)[0]
- # raise SystemExit code 17 if no status message is received
- except TypeError:
+ tmp = status.split()[2]
+
+ except AttributeError:
+ # emtpy response or None obj
raise SystemExit(17)
+ except IndexError:
+ # status string differs from what we expect
+ log.warning("status string is different then expected")
+ tmp = "ejabberd@status-string-split-error"
+ pass
+
+ # strip double quotations
+ if tmp.startswith("'"):
+ tmp = tmp.strip("'")
+
log.debug(f"fetched node string: {tmp}")
return tmp