From 29330aee747078685f2f1a896209d0e065b6b9cf Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 13 Nov 2017 14:04:09 -0500 Subject: [PATCH] Clear [powered off] from screen if state change detected Previously, only transition to powered on was detected. React to situations where data comes up or power status change. --- confluent_client/bin/confetty | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index e490ebb1..f83913f5 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -76,6 +76,7 @@ import confluent.tlvdata as tlvdata import confluent.client as client conserversequence = '\x05c' # ctrl-e, c +clearpowermessage = False oldtcattr = None fd = sys.stdin @@ -115,7 +116,7 @@ def print_help(): def updatestatus(stateinfo={}): - global powerstate, powertime + global powerstate, powertime, clearpowermessage status = consolename info = [] for statekey in stateinfo: @@ -134,6 +135,10 @@ def updatestatus(stateinfo={}): newpowerstate = stateinfo['state']['value'] if newpowerstate != powerstate and newpowerstate == 'off': sys.stdout.write("\x1b[2J\x1b[;H[powered off]\r\n") + clearpowermessage = True + if newpowerstate == 'on' and clearpowermessage: + sys.stdout.write("\x1b[2J\x1b[;H") + clearpowermessage = False powerstate = newpowerstate if 'clientcount' in laststate and laststate['clientcount'] != 1: info.append('clients: %d' % laststate['clientcount']) @@ -878,6 +883,9 @@ while inconsole or not doexit: updatestatus(data) continue if data is not None: + if clearpowermessage: + sys.stdout.write("\x1b[2J\x1b[;H") + clearpowermessage = False try: sys.stdout.write(data) except IOError: # Some times circumstances are bad