From 5a504220aac23657bbaf126f8a1524edc9587d9d Mon Sep 17 00:00:00 2001 From: David Bartley Date: Tue, 18 Dec 2007 01:49:13 -0500 Subject: [PATCH] Improve exception handling --- ceo/urwid/groups.py | 4 ++-- ceo/urwid/positions.py | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ceo/urwid/groups.py b/ceo/urwid/groups.py index 44052fb..fc387e3 100644 --- a/ceo/urwid/groups.py +++ b/ceo/urwid/groups.py @@ -115,14 +115,14 @@ class EndPage(WizardPanel): for group in data['groups']: try: members.change_group_member(action, group, self.state['userid']) - except: + except ldap.LDAPError: failed.append(group) if len(failed) == 0: self.headtext.set_text("%s succeeded" % data['action']) self.midtext.set_text("Congratulations, the group modification " "has succeeded.") else: - self.headtext.set_text("%s partially succeeded" % data['action']) + self.headtext.set_text("%s Results" % data['action']) self.midtext.set_text("Failed to %s member to %s for the " "following groups: %s. This may indicate an attempt to add a " "duplicate group member or to delete a member that was not in " diff --git a/ceo/urwid/positions.py b/ceo/urwid/positions.py index 28f324a..953887f 100644 --- a/ceo/urwid/positions.py +++ b/ceo/urwid/positions.py @@ -76,11 +76,20 @@ class EndPage(WizardPanel): def focusable(self): return False def activate(self): + failed = [] for (position, info) in self.state['positions'].iteritems(): - members.set_position(position, info) - self.headtext.set_text("Positions Updated") - self.midtext.set_text("Congratulations, positions have been updated. " - "You should rebuild the website in order to update the Positions " - "page.") + try: + members.set_position(position, info) + except ldap.LDAPError: + failed.append(position) + if len(failed) == 0: + self.headtext.set_text("Positions Updated") + self.midtext.set_text("Congratulations, positions have been " + "updated. You should rebuild the website in order to update " + "the Positions page.") + else: + self.headtext.set_text("Positions Results") + self.midtext.set_text("Failed to update the following positions: " + "%s." % join(failed)) def check(self): pop_window()