9: Device Ports
SLCâ„¢ 8000 Advanced Console Manager User Guide 219
'login:', 'Error: (.*)\r\n',
'>'], timeout=10)
if i == 0: # Timeout
cnt = cnt + 1
if cnt == 3:
print("Timeout waiting to connect to DP", devicePort, ".")
p.terminate(True)
p.wait()
break
# may need to send a CR to get prompt
p.send("\r")
elif i == 1: # EOF
print("portsession on DP ", devicePort, "unexpectedly
terminated.")
break
elif i == 2: # login prompt
p.sendline("sysadmin")
p.expect("Password:")
p.sendline("PASS")
slcDevice = True
gotPrompt = True
elif i == 3: # error from portsession
print(p.match.group(1).decode('utf-8'))
p.terminate(True)
p.wait()
break
elif i == 4: # prompt
gotPrompt = True
# end if while not gotPrompt:
if not gotPrompt:
devicePort = devicePort + 1
pList.append('')
continue
# Detect the prompt
devPrompt = ""
p.send("\n")
i = p.expect([pexpect.TIMEOUT, pexpect.EOF, '\r\n(.*)>'],
timeout=10)
if i == 0 or i == 1: # Timeout or EOF
print("Timeout waiting for the prompt on DP", devicePort, ".")
p.terminate(True)
p.wait()
devicePort = devicePort + 1
pList.append('')
continue
if i == 2: # prompt
devPrompt = p.match.group(1).decode('utf-8')
if devPrompt == "":
print("Timeout waiting for the prompt on DP", devicePort, ".")
devicePort = devicePort + 1
pList.append('')