From d2d8ef2880f256af752ac362fdba34d3f64c3526 Mon Sep 17 00:00:00 2001 From: vela-jabber Date: Sat, 17 Apr 2021 17:07:42 +0200 Subject: improve calls --- calls.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/calls.py b/calls.py index d4c8f2c..94e8dde 100644 --- a/calls.py +++ b/calls.py @@ -22,6 +22,7 @@ class EjabberdApiCalls(EjabberdApi): except AttributeError: # emtpy response or None obj + log.warning("nodename not found on split") raise SystemExit(17) except IndexError: @@ -50,6 +51,7 @@ class EjabberdApiCalls(EjabberdApi): tmp = ver_str.findall(status)[0] # raise SystemExit code 17 if no status message is received except TypeError: + log.warning("ver sting not parsed") raise SystemExit(17) # return parsed version string @@ -93,25 +95,39 @@ class EjabberdApiCalls(EjabberdApi): def fetch_s2s_in(self): result = self.cmd("incoming_s2s_number", {}) - if "s2s_incoming" not in result: - return result - return result["s2s_incoming"] + if isinstance(result, dict): + if "s2s_incoming" in result: + return result["s2s_incoming"] + log.warning("fetch_s2s_in: error empty result " + str(result)) + return 0 + return result def fetch_s2s_out(self): result = self.cmd("outgoing_s2s_number", {}) - if "s2s_outgoing" not in result: - return result - return result["s2s_outgoing"] + if isinstance(result, dict): + if "s2s_outgoing" in result: + return result["s2s_outgoing"] + log.warning("fetch_s2s_out: error empty result " + str(result)) + return 0 + return result def fetch_uptime(self): result = self.cmd("stats", {"name": "uptimeseconds"}) - if "stat" in result: - return result["stat"] + if isinstance(result, dict): + if "stat" in result: + return result["stat"] + log.warning("uptime: error empty result " + str(result)) + return 0 + return result def fetch_processes(self): result = self.cmd("stats", {"name": "processes"}) - if "stat" in result: - return result["stat"] + if isinstance(result, dict): + if "stat" in result: + return result["stat"] + log.warning("processes: error empty result " + str(result)) + return 0 + return result def fetch_registered_count(self, vhost=None): if vhost is None: -- cgit v1.2.3-54-g00ecf