From: Alex Dehnert Date: Sat, 12 Oct 2013 18:03:23 +0000 (-0400) Subject: rblanche: avoid crashing on deactivated users X-Git-Url: https://www.dehnerts.com/gitweb/?p=user%2Falex%2Fsoftware%2Fmy-snippets.git;a=commitdiff_plain;h=a0db65ec648a1e6238a508a9137b5311693dd0b2 rblanche: avoid crashing on deactivated users When chpoboxing (-c), we get_pobox for each user. moira returns an error for (some) deactivated users, so we should catch that error and report it inline, rather than erroring out entirely. This was discovered by rblanche'ing sipb-prospectives. --- diff --git a/rblanche.py b/rblanche.py index fb31a42..9eb995f 100755 --- a/rblanche.py +++ b/rblanche.py @@ -33,7 +33,10 @@ class RBlanche(object): return members def get_and_format_pobox(self, user): - result = moira.query('get_pobox', user)[0] + try: + result = moira.query('get_pobox', user)[0] + except moira.MoiraException, e: + return "%8s ** moira error: %s **" % (user, e) if result['type'] == 'SMTP': fmt = '-> %s' elif result['type'] == 'SPLIT':