From 69e6c6befad894bc714c9c841d1c5e717c0cabc5 Mon Sep 17 00:00:00 2001 From: Joe Guo Date: Fri, 11 May 2018 11:50:38 +1200 Subject: [PATCH] traffic: uniform stats output The original code is trying to output different data format for tty or file. This is unnecessary and cause confusion while writing script to parse result. The human-readable one is also easy for code to parse. Remove if check for isatty(), just make output the same. Signed-off-by: Joe Guo --- python/samba/emulate/traffic.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py index afb57da36f0..a020b14a6fd 100644 --- a/python/samba/emulate/traffic.py +++ b/python/samba/emulate/traffic.py @@ -1939,25 +1939,16 @@ def tw(x): else: failure_rate = failed / duration - # print the stats in more human-readable format when stdout is going to the - # console (as opposed to being redirected to a file) - if sys.stdout.isatty(): - print("Total conversations: %10d" % conversations) - print("Successful operations: %10d (%.3f per second)" - % (successful, success_rate)) - print("Failed operations: %10d (%.3f per second)" - % (failed, failure_rate)) - else: - print("(%d, %d, %d, %.3f, %.3f)" % - (conversations, successful, failed, success_rate, failure_rate)) + print("Total conversations: %10d" % conversations) + print("Successful operations: %10d (%.3f per second)" + % (successful, success_rate)) + print("Failed operations: %10d (%.3f per second)" + % (failed, failure_rate)) + + print("Protocol Op Code Description " + " Count Failed Mean Median " + "95% Range Max") - if sys.stdout.isatty(): - print("Protocol Op Code Description " - " Count Failed Mean Median " - "95% Range Max") - else: - print("proto\top_code\tdesc\tcount\tfailed\tmean\tmedian\t95%\trange" - "\tmax") protocols = sorted(latencies.keys()) for protocol in protocols: packet_types = sorted(latencies[protocol], key=opcode_key)