]> git.ipfire.org Git - ipfire.org.git/commitdiff
asterisk: roundtrip: Don't fail on no value
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Jul 2023 15:35:14 +0000 (15:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 11 Jul 2023 15:36:07 +0000 (15:36 +0000)
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 <michael.tremer@ipfire.org>
src/backend/asterisk.py
src/templates/voip/modules/registrations.html

index d9b9c63ee44f62cf6d75fdb17686fd97897baeda..cedaeaced3c199142cb17770fccae5e5f4dcb956 100644 (file)
@@ -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):
index 0edfac9e6d8b165604db8e711b32b6a8c8771b83..f025229c6fc156f1441a4f55c2e1b074f4a4c0c9 100644 (file)
 
                                {# Latency #}
                                <td class="has-text-right">
-                                       {{ _("%.2fms") % r.roundtrip }}
+                                       {% if r.roundtrip %}
+                                               {{ _("%.2fms") % r.roundtrip }}
+                                       {% else %}
+                                               {{ _("N/A") }}
+                                       {% end %}
                                </th>
                        </tr>
                {% end %}