mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-02 03:37:55 +00:00
more specific exception
This commit is contained in:
@@ -311,11 +311,7 @@ def main():
|
|||||||
port = 23
|
port = 23
|
||||||
cmd = "telnet %s %d"%(host, port)
|
cmd = "telnet %s %d"%(host, port)
|
||||||
logg.info("Spawn: "+cmd+NL)
|
logg.info("Spawn: "+cmd+NL)
|
||||||
try:
|
egg = pexpect.spawn(cmd)
|
||||||
egg = pexpect.spawn(cmd)
|
|
||||||
except:
|
|
||||||
print("Telnet failed exiting")
|
|
||||||
exit(1)
|
|
||||||
egg.logfile = FileAdapter(logg)
|
egg.logfile = FileAdapter(logg)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
logged_in_9800 = False
|
logged_in_9800 = False
|
||||||
@@ -324,7 +320,15 @@ def main():
|
|||||||
if args.series == "9800":
|
if args.series == "9800":
|
||||||
while logged_in_9800 == False and loop_count <= 2:
|
while logged_in_9800 == False and loop_count <= 2:
|
||||||
#egg.sendline(CR)
|
#egg.sendline(CR)
|
||||||
i = egg.expect_exact(["Escape character is '^]'.",">","#","ser\:","ssword\:",pexpect.TIMEOUT],timeout=2)
|
try:
|
||||||
|
i = egg.expect_exact(["Escape character is '^]'.",">","#","ser\:","ssword\:",pexpect.TIMEOUT],timeout=2)
|
||||||
|
except pexpect.EOF as e:
|
||||||
|
print('connection failed. or refused')
|
||||||
|
exit(1)
|
||||||
|
except:
|
||||||
|
print('unknown exception on initial pexpect after login')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
if i == 0:
|
if i == 0:
|
||||||
print("9800 found Escape charter is sending carriage return i: {} before: {} after: {}".format(i,egg.before,egg.after))
|
print("9800 found Escape charter is sending carriage return i: {} before: {} after: {}".format(i,egg.before,egg.after))
|
||||||
egg.sendline(CR)
|
egg.sendline(CR)
|
||||||
|
|||||||
Reference in New Issue
Block a user