From fd0edb2bb16012826f49a6916932608ba3fffdaa Mon Sep 17 00:00:00 2001 From: Mathew S <128190304+mshak2@users.noreply.github.com> Date: Fri, 8 Nov 2024 01:32:26 -0700 Subject: [PATCH] Fix issue #1241 - make sr3 status display more compact (#1290) * Fix #1241 - make sr3 status display more compact * Fix bug where 3 unlabeled dashes were being printed * Adjust printing alignment * Fix "Rates" header positioning * Fix dashes * adjusting missing data dash placement --------- Co-authored-by: Peter Silva --- sarracenia/sr.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/sarracenia/sr.py b/sarracenia/sr.py index 8a6b07d3c..826f8f610 100755 --- a/sarracenia/sr.py +++ b/sarracenia/sr.py @@ -2566,8 +2566,8 @@ def status(self): flowNameWidth=self.cumulative_stats['flowNameWidth'] latestTransferWidth=self.cumulative_stats['latestTransferWidth'] - lfmt = f"%-{flowNameWidth}s %-11s %7s %10s %19s %14s %38s " - line = lfmt % ("Component/Config", "Processes", "Connection", "Lag", "", "Rates", "" ) + lfmt = f"%-{flowNameWidth}s %-49s %s" + line = lfmt % ("Component/Config", "Processes", "Rates" ) if self.options.displayFull: line += "%10s %-40s %17s %33s %40s" % ("", "Counters (per housekeeping)", "", "Data Counters", "" ) @@ -2579,9 +2579,9 @@ def status(self): try: print(line) - lfmt = f"%-{flowNameWidth}s %-5s %5s %5s %4s %4s %5s %8s %8s %{latestTransferWidth}s %5s %10s %10s %10s %10s " - line = lfmt % ("", "State", "Run", "Retry", "msg", "data", "Que", "LagMax", "LagAvg", "Last", "%rej", "pubsub", "messages", "RxData", "TxData" ) - underline = lfmt % ("", "-----", "---", "-----", "---", "----", "---", "------", "------", "----", "----", "------", "--------", "------", "------" ) + lfmt = f"%-{flowNameWidth}s %-5s %5s %5s %4s %7s %{latestTransferWidth + 1}s %7s %9s %9s " + line = lfmt % ("", "State", "Run", "Retry", "Que", "Lag", "Last", "%rej", "messages", "Data" ) + underline = lfmt % ("", "-----", "---", "-----", "---", "---", "----", "----", "--------", "----" ) if self.options.displayFull: line += "%10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %8s " % \ @@ -2648,14 +2648,12 @@ def status(self): if 'metrics' in self.states[c][cfg]: m=self.states[c][cfg]['metrics'] - lfmt = f"%5d %3d%% %3d%% %5d %8s %8s %{latestTransferWidth}s %4.1f%% %8s/s %8s/s %8s/s %8s/s " - line += lfmt % ( m['retry'], m['connectPercent'], m['byteConnectPercent'], \ - m['messagesQueued'], durationToString(m['lagMax']), durationToString(m['lagMean']), m['latestTransfer'], m['rejectPercent'],\ - naturalSize(m['byteRate']).replace("Bytes","B"), \ + lfmt = f"%4d %4d %8s %{latestTransferWidth + 1}s %6.1f%% %6s/s %8s/s " + line += lfmt % ( m['retry'], \ + m['messagesQueued'], durationToString(m['lagMean']), m['latestTransfer'], m['rejectPercent'],\ naturalSize(m['msgRate']).replace("B","m").replace("mytes","m"), \ - naturalSize(m['transferRxByteRate']).replace("Bytes","B"), \ - naturalSize(m['transferTxByteRate']).replace("Bytes","B") - ) + naturalSize(m['transferRxByteRate'] + m['transferTxByteRate']).replace("Bytes","B")) + if self.options.displayFull : line += "%10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %7.2fs " % ( \ @@ -2673,7 +2671,7 @@ def status(self): naturalSize(m["transferTxFiles"]).replace("B","F").replace("Fytes","f"), \ m["time_base"] ) else: - line += "%10s %10s %9s %5s %5s %10s %8s " % ( "-", "-", "-", "-", "-", "-", "-" ) + line += "%4s %4s %7s %6s %7s %7s %11s " % ( "-", "-", "-", "-", "-", "-", "-" ) if self.options.displayFull: line += "%8s %7s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s" % \ ( "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ) @@ -2690,8 +2688,8 @@ def status(self): ru['user_cpu'], ru['system_cpu'] \ ) else: - line += "%10s %10s %10s" % ( "-", "-", "-" ) if self.options.displayFull: + line += "%10s %10s %10s" % ( "-", "-", "-" ) line += "%10s %10s" % ( "-", "-" ) try: print(line)