diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index f53649e6..89296ff6 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -651,11 +651,7 @@ def conserver_command(filehandle, localcommand): else: print("Unknown power state.]\r") - global powerstate - powerstate = list(session.read('/nodes/' + consolename + '/power/state'))[0]['state']['value'] - powertime = time.time() - if powerstate == 'off': - sys.stdout.write("\r\n[powered off]\r\n") + check_power_state() elif localcommand[0] == '?': print("help]\r") @@ -765,6 +761,25 @@ elif shellargs: powerstate = None powertime = None + + +def check_power_state(): + global powerstate, powertime + for rsp in session.read('/nodes/' + consolename + '/power/state'): + if type(rsp) == dict and 'state' in rsp: + powerstate = rsp['state']['value'] + powertime = time.time() + if powerstate == 'off': + sys.stdout.write("\r\n[powered off]\r\n") + elif type(rsp) == dict and '_requestdone' in rsp: + break + elif type(rsp) == dict: + updatestatus(rsp) + else: + sys.stdout.write(rsp) + sys.stdout.flush() + + while inconsole or not doexit: if inconsole: rdylist, _, _ = select.select( @@ -819,10 +834,8 @@ while inconsole or not doexit: if myinput: tlvdata.send(session.connection, myinput) if powerstate is None or powertime < time.time() - 60: # Check powerstate every 60 seconds - powerstate = list(session.read('/nodes/' + consolename + '/power/state'))[0]['state']['value'] - powertime = time.time() - if powerstate == 'off': - sys.stdout.write("\r\n[powered off]\r\n") + check_power_state() + else: currcommand = prompt() try: