Catch exception when trying to list missing managed entries definitions

On the off chance that the definitions cannot be found we should
catch the error and not raise a backtrace.

https://fedorahosted.org/freeipa/ticket/1912
This commit is contained in:
Rob Crittenden 2012-01-12 18:27:08 -05:00
parent 64b0855e87
commit 638a970172

View File

@ -127,9 +127,13 @@ def main():
if options.list_managed_entries: if options.list_managed_entries:
# List available Managed Entry Plugins # List available Managed Entry Plugins
managed_entries = None managed_entries = None
entries = conn.search_s( try:
managed_entry_definitions_dn, ldap.SCOPE_SUBTREE, filter entries = conn.search_s(
) managed_entry_definitions_dn, ldap.SCOPE_SUBTREE, filter
)
except Exception, e:
root_logger.debug("Search for managed entries failed: %s" % str(e))
sys.exit("Unable to find managed entries at %s" % managed_entry_definitions_dn)
managed_entries = [entry.cn for entry in entries] managed_entries = [entry.cn for entry in entries]
if managed_entries: if managed_entries:
print "Available Managed Entry Definitions:" print "Available Managed Entry Definitions:"