cisco_ap_ctl.py cisco_wifi_ctl.py : LCS-45 Read AP for Power

remember to send info to stdout (have to do a print )
This commit is contained in:
Chuck SmileyRekiere
2021-01-22 17:39:22 -07:00
parent bcc21fecbc
commit f813db7509
2 changed files with 9 additions and 4 deletions

View File

@@ -205,6 +205,8 @@ def main():
if (args.action == "powercfg"):
logg.info("execute: show controllers dot11Radio 1 powercfg | g T1")
egg.sendline('show controllers dot11Radio 1 powercfg | g T1')
egg.expect([pexpect.TIMEOUT], timeout=3) # do not delete this allows for subprocess to see output
print(egg.before.decode('utf-8', 'ignore')) # do not delete this allows for subprocess to see output
i = egg.expect_exact([AP_MORE,pexpect.TIMEOUT],timeout=5)
if i == 0:
egg.sendcontrol('c')
@@ -215,6 +217,9 @@ def main():
else: # no other command at this time so send the same power command
logg.info("no action so execute: show controllers dot11Radio 1 powercfg | g T1")
egg.sendline('show controllers dot11Radio 1 powercfg | g T1')
egg.expect([pexpect.TIMEOUT], timeout=3) # do not delete this allows for subprocess to see output
print(egg.before.decode('utf-8', 'ignore')) # do not delete this allows for subprocess to see output
i = egg.expect_exact([AP_MORE,pexpect.TIMEOUT],timeout=5)
if i == 0:
egg.sendcontrol('c')

View File

@@ -559,15 +559,15 @@ def main():
egg.sendline(CR)
sleep(0.4)
try:
i = egg.expect_exact(["Escape character is '^]'.",CCP,CCP_EN,"User:","Password:",CCP_CONFIG,"Bad secrets", PRESS_RETURN, CONFIG_I,pexpect.TIMEOUT],timeout=2)
i = egg.expect_exact(["Escape character is '^]'.",CCP,CCP_EN,"Username:","Password:",CCP_CONFIG,"Bad secrets", PRESS_RETURN, CONFIG_I,pexpect.TIMEOUT],timeout=2)
except Exception as e:
logg.info('connection failed. or refused Connection open by other process')
logg.info('AP connection failed. or refused Connection open by other process')
logg.exception(e)
exit(1)
if i == 0:
logg.info("9800 found Escape character is '^] i:{} before: {} after: {}".format(i,egg.before,egg.after))
egg.sendline(CR) # 1/18/2021 - may need a bit more logic
egg.sendline(CR)
found_escape = True
sleep(0.2)
j = egg.expect_exact([CCP,CCP_EN,"User:","Password:",CCP_CONFIG,pexpect.TIMEOUT],timeout=3)
@@ -1340,7 +1340,7 @@ def main():
while logged_out_9800 == False and loop_count <= 6:
loop_count += 1
i = egg.expect_exact([CCP,CCP_EN, CCP_CONFIG,CCP_CONFIG_WLAN,CCP_POLICY_TAG,CCP_CONFIG_LINE,pexpect.TIMEOUT],timeout=5)
print (egg.before.decode('utf-8', 'ignore'))
print (egg.before.decode('utf-8', 'ignore')) # allows program that calls from subprocess to see output from command
if i == 0:
logg.info("{} prompt received can send logout, loop_count: {}".format(CCP,loop_count))
egg.sendline("logout")