def __get_fas_user_by_email(email_address): ''' For a provided email_address returned the associated FAS user. The email_address can be either the FAS email address or the one used in bugzilla. :arg email_address: the email address of the user to retrieve in FAS. ''' if email_address in FASCLIENT._AccountSystem__alternate_email: userid = FASCLIENT._AccountSystem__alternate_email[email_address] else: try: userid = FASCLIENT.people_query( constraints={'email': email_address}, columns=['id']) except AuthError: username, password = pkgdb2client.ask_password() FASCLIENT.username = username FASCLIENT.password = password userid = FASCLIENT.people_query( constraints={'email': email_address}, columns=['id']) if userid: userid = userid[0].id user = None if userid: try: user = FASCLIENT.person_by_id(userid) except AuthError: username, password = pkgdb2client.ask_password() FASCLIENT.username = username FASCLIENT.password = password user = FASCLIENT.person_by_id(userid) return user
def is_packager(user): ''' For a provided user returned whether associated FAS user is a packager or not. The user can be either the username or an email. If the user is an email address, it can be either the FAS email address or the one used in bugzilla. :arg email_address: the email address of the user to retrieve in FAS. ''' FASCLIENT = _get_fas() if '@' in user: fas_user = __get_fas_user_by_email(user.strip()) else: try: fas_user = FASCLIENT.person_by_username(user) except AuthError: username, password = pkgdb2client.ask_password() FASCLIENT.username = username FASCLIENT.password = password fas_user = FASCLIENT.person_by_username(user) return fas_user \ and 'packager' in fas_user['group_roles'] \ and fas_user['group_roles']['packager']['role_status'] == 'approved'
def __get_fas_user_by_email(email_address): ''' For a provided email_address returned the associated FAS user. The email_address can be either the FAS email address or the one used in bugzilla. :arg email_address: the email address of the user to retrieve in FAS. ''' FASCLIENT = _get_fas() if email_address in FASCLIENT._AccountSystem__alternate_email: userid = FASCLIENT._AccountSystem__alternate_email[email_address] else: try: userid = FASCLIENT.people_query( constraints={'email': email_address}, columns=['id'] ) except AuthError: username, password = pkgdb2client.ask_password() FASCLIENT.username = username FASCLIENT.password = password userid = FASCLIENT.people_query( constraints={'email': email_address}, columns=['id'] ) if userid: userid = userid[0].id user = None if userid: try: user = FASCLIENT.person_by_id(userid) except AuthError: username, password = pkgdb2client.ask_password() FASCLIENT.username = username FASCLIENT.password = password user = FASCLIENT.person_by_id(userid) return user