I'm working on a program that telnets to multiple devices to test their backup ISDN BRI connections. I'm trying to build in error recovery with try/except logic, but I'm having trouble getting it to work. This first example uses a host name that isn't in our DNS (yes, this does happen):
import telnetlib host = "s3793ap01" telnetlib.Telnet(host)
Traceback (most recent call last): File "<pyshell#30>", line 1, in <module> telnetlib.Telnet(host) File "c:\python25\lib\telnetlib.py", line 208, in __init__ self.open(host, port) File "c:\python25\lib\telnetlib.py", line 225, in open for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): gaierror: (11001, 'getaddrinfo failed')
try:
telnetlib.Telnet(host) except gaierror, e: print "error found", e Traceback (most recent call last): File "<pyshell#16>", line 3, in <module> except gaierror, e: NameError: name 'gaierror' is not defined
try:
telnetlib.Telnet(host) except IOError, e: print "error found", e Traceback (most recent call last): File "<pyshell#22>", line 2, in <module> telnetlib.Telnet(host) File "c:\python25\lib\telnetlib.py", line 208, in __init__ self.open(host, port) File "c:\python25\lib\telnetlib.py", line 225, in open for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): gaierror: (11001, 'getaddrinfo failed') As you can see, I'm not sure how to handle the error. Any ideas?
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor