|
From: Richard H. <hol...@os...> - 2002-05-09 19:01:11
|
Dear Michael,
I've ran into a problem with the way the exception handler error messages are
returned by python-ldap.
I'm trying to print exception handler error messages using the following:
try:
l.simple_bind_s(login_dn, login_pw)
except ldap.LDAPError, e:
print "BINDFAILED", e
sys.exit(1)
But it doesn't work as expected. Here's what I get:
BINDFAILED {'desc': "Can't contact LDAP server"}
This is because your exception handler returns e is an instance of a
dictionary, so I have to do the following:
try:
l.simple_bind_s(login_dn, login_pw)
except ldap.LDAPError, e:
print "BINDFAILED", e.args[0]['desc']
sys.exit(1)
To get:
BINDFAILED Can't contact LDAP server
The exception handler in IO is a bit more straight forward.
This example:
try:
input = open("config.txt","r")
except IOError, e:
print "CONFIGFILEERROR", e
sys.exit(1)
yields the following:
CONFIGFILEERROR [Errno 2] No such file or directory: 'config.txt'
Thanks!
Rick
|