2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 09:32:21 +00:00

Suppress redundant output when writing to non-tty

This commit is contained in:
Jarrod Johnson 2022-12-12 13:41:48 -05:00
parent 7ccd1a42cd
commit 511fbe987b

View File

@ -50,9 +50,9 @@ class ScreenPrinter(object):
if len(text) >= self.textlen:
self.textlen = len(text) + 1
self.fieldwidth = self.textlen + self.nodenamelen + 1
self.drawscreen()
self.drawscreen(node)
def drawscreen(self):
def drawscreen(self, node=None):
if self.squeeze:
currheight, currwidth = get_screengeom()
currheight -= 1
@ -76,7 +76,11 @@ class ScreenPrinter(object):
break
sys.stdout.write('\n')
else:
for node in self.nodelist:
if node:
nodes = [node]
else:
nodes = self.nodelist
for node in nodes:
sys.stdout.write(fieldformat.format(node, self.nodeoutput[node]))
sys.stdout.write('\n')
sys.stdout.flush()