From df3e4d317bfbd1da2f411bbb8c7736c4b1812fb1 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 11 Jul 2023 15:35:14 +0000 Subject: [PATCH] asterisk: roundtrip: Don't fail on no value If the peer could not be reached, RoundtripUsec contains "N/A" which we will now catch and return nothing instead. Signed-off-by: Michael Tremer --- src/backend/asterisk.py | 5 ++++- src/templates/voip/modules/registrations.html | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/backend/asterisk.py b/src/backend/asterisk.py index d9b9c63e..cedaeace 100644 --- a/src/backend/asterisk.py +++ b/src/backend/asterisk.py @@ -214,7 +214,10 @@ class Registration(misc.Object): @property def roundtrip(self): - return int(self.data.RoundtripUsec) / 1000 + try: + return int(self.data.RoundtripUsec) / 1000 + except ValueError: + pass class OutboundRegistration(misc.Object): diff --git a/src/templates/voip/modules/registrations.html b/src/templates/voip/modules/registrations.html index 0edfac9e..f025229c 100644 --- a/src/templates/voip/modules/registrations.html +++ b/src/templates/voip/modules/registrations.html @@ -40,7 +40,11 @@ {# Latency #} - {{ _("%.2fms") % r.roundtrip }} + {% if r.roundtrip %} + {{ _("%.2fms") % r.roundtrip }} + {% else %} + {{ _("N/A") }} + {% end %} {% end %} -- 2.47.3