From 54a4660d105fac3b954e70acfc25b5dd929fe766 Mon Sep 17 00:00:00 2001 From: Benjamin Collet Date: Thu, 17 Jan 2019 17:39:24 +0100 Subject: [PATCH] Truncate overflowing strings --- client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client.py b/client.py index e39abe4..a312193 100755 --- a/client.py +++ b/client.py @@ -28,11 +28,13 @@ def call_api(params, path): def print_data(key, value, suffix = None): if suffix is not None: - print("(0x(B %-18s (0x(B %s %-*s (0x(B" % - (key, value, term_cols - 26 - len(value) , suffix)) + value_cols = term_cols - 26 - len(value) + print("(0x(B %-18s (0x(B %s %-*.*s (0x(B" % + (key, value, value_cols, value_cols, suffix)) else: - print("(0x(B %-18s (0x(B %-*s (0x(B" % - (key, term_cols - 25, value)) + value_cols = term_cols - 25 + print("(0x(B %-18s (0x(B %-*.*s (0x(B" % + (key, value_cols, value_cols, value)) # Test instances for instance in list(cfg['instances']):