From 3d6af021147425c23d4deeb453a9255b0adeb5ae Mon Sep 17 00:00:00 2001 From: Anna Makarudze Date: Tue, 7 Mar 2023 20:48:35 +0200 Subject: [PATCH 1/2] Catch HttpError when creating/migrating emails --- core/gmail_accounts.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/core/gmail_accounts.py b/core/gmail_accounts.py index e4baa69ca..60cda06f3 100644 --- a/core/gmail_accounts.py +++ b/core/gmail_accounts.py @@ -52,18 +52,21 @@ def create_gmail_account(event): if not service: return None, None - service.users().insert( - body={ - "primaryEmail": email, - "name": { - "fullName": event.name, - "givenName": "Django Girls", - "familyName": event.city, - }, - "password": password, - "changePasswordAtNextLogin": True, - } - ).execute() + try: + service.users().insert( + body={ + "primaryEmail": email, + "name": { + "fullName": event.name, + "givenName": "Django Girls", + "familyName": event.city, + }, + "password": password, + "changePasswordAtNextLogin": True, + } + ).execute() + except HttpError: + pass return email, password From 40f0b362af00f4a9841977fcd193c372faf43659 Mon Sep 17 00:00:00 2001 From: Anna Makarudze Date: Tue, 7 Mar 2023 20:58:23 +0200 Subject: [PATCH 2/2] Return None if HttpError --- core/gmail_accounts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/gmail_accounts.py b/core/gmail_accounts.py index 60cda06f3..b4c03a231 100644 --- a/core/gmail_accounts.py +++ b/core/gmail_accounts.py @@ -66,7 +66,7 @@ def create_gmail_account(event): } ).execute() except HttpError: - pass + return None, None return email, password