From 43bdf051de37ddc5aee991a566007e22f51f8a27 Mon Sep 17 00:00:00 2001 From: David Moreno Date: Fri, 15 Dec 2023 16:58:38 +0100 Subject: [PATCH] Fix top latency measurements with stddev --- cli/rtpmidid-cli.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cli/rtpmidid-cli.py b/cli/rtpmidid-cli.py index 8a99ed7..b8a7c54 100755 --- a/cli/rtpmidid-cli.py +++ b/cli/rtpmidid-cli.py @@ -15,10 +15,10 @@ def __init__(self, filename): self.socket.connect(filename) except ConnectionRefusedError: print( - "Connection refused to %s. Change control socket location with RTPMIDID_SOCKET environment var." + "Connection refused to %s. Can set other location with --control=" % filename ) - raise + sys.exit(1) def command(self, command): self.socket.send(json.dumps(command).encode("utf8") + b"\n") @@ -126,6 +126,14 @@ def getter(data): return getter +def latency_getter(data): + avg = safe_getter("peer", "latency_ms", "average")(data) + if not avg: + return "" + stddev = safe_getter("peer", "latency_ms", "stddev")(data) + return f"{avg}ms \u00B1 {stddev}ms" + + COLUMNS = [ { "name": "ID", @@ -165,8 +173,9 @@ def getter(data): }, { "name": "Latency", - "get": lambda x: f'{safe_getter("peer", "latency_ms")(x)}ms', - "width": 8, + # the unicode symbol for +- is \u00B1 + "get": latency_getter, + "width": 20, "align": "right", }, {