From d61e83a1570cbcdede44d5f6e8beab1ff0819344 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Wed, 20 Nov 2019 10:52:20 +0100 Subject: [PATCH] Deal with users or groups not having the expected email address An user could have no "bugzilla_email" set and a group no "mailing_list" address set, both of which are expected to sync the ACLs to bugzilla. Signed-off-by: Pierre-Yves Chibon --- distgit_bugzilla_sync/script.py | 36 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/distgit_bugzilla_sync/script.py b/distgit_bugzilla_sync/script.py index 9ac34cf..12bc3d2 100644 --- a/distgit_bugzilla_sync/script.py +++ b/distgit_bugzilla_sync/script.py @@ -199,16 +199,18 @@ class BugzillaProxy: except KeyError: if username.startswith('@'): group = self.fas.group_by_name(username[1:]) + bz_email = group.mailing_list + if bz_email is None: + return self.userCache[username] = { - 'bugzilla_email': group.mailing_list} + 'bugzilla_email': bz_email} else: person = self.fas.person_by_username(username) bz_email = person.get('bugzilla_email', None) if bz_email is None: - print('%s has no bugzilla email, valid account?' - % username) - else: - self.userCache[username] = {'bugzilla_email': bz_email} + + return + self.userCache[username] = {'bugzilla_email': bz_email} return self.userCache[username]['bugzilla_email'].lower() def add_edit_component(self, package, collection, owner, description=None, @@ -216,15 +218,21 @@ class BugzillaProxy: '''Add or update a component to have the values specified. ''' # Turn the cclist into something usable by bugzilla - initialCCList = list() - if 'people' in cclist: - user_cc = [ - self._get_bugzilla_email(cc) for cc in cclist['people']] - initialCCList.extend(user_cc) - if 'groups' in cclist: - group_cc = [ - self._get_bugzilla_email(cc) for cc in cclist['groups']] - initialCCList.extend(group_cc) + initialCCList = [] + if cclist and 'people' in cclist: + for cc in cclist["people"]: + bz_email = self._get_bugzilla_email(cc) + if bz_email: + initialCCList.append(bz_email) + else: + print(f"** {cc} has no bugzilla_email or mailing_list set **") + if cclist and 'groups' in cclist: + for cc in cclist["groups"]: + bz_email = self._get_bugzilla_email(cc) + if bz_email: + initialCCList.append(bz_email) + else: + print(f"** {cc} has no mailing-list set in FAS! **") # Add owner to the cclist so comaintainers taking over a bug don't # have to do this manually