Skip to content

Commit

Permalink
Google API cleanup. Dont use cache due to import error.
Browse files Browse the repository at this point in the history
  • Loading branch information
kduncklee committed Oct 30, 2020
1 parent 06223ec commit fad19d0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion main/lib/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __new__(cls):
if not c:
return NoopAdminDirectory()
instance.directory = googleapiclient.discovery.build(
'admin', 'directory_v1', credentials=c)
'admin', 'directory_v1', credentials=c, cache_discovery=False)
if not instance.directory:
return NoopAdminDirectory()
return instance
Expand Down
7 changes: 4 additions & 3 deletions main/lib/gcal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dateutil.parser
import googleapiclient.discovery
import googleapiclient.errors
from google.auth.exceptions import GoogleAuthError
from django.conf import settings
from django.utils import timezone
Expand Down Expand Up @@ -71,7 +72,7 @@ def sync_event(self, bamru_event, save=True):
body=build_gcal_event(bamru_event),
).execute()
bamru_event.gcal_id = new_event['id']
except GoogleAuthError as e:
except (googleapiclient.errors.HttpError, GoogleAuthError) as e:
logger.error("Gcal create error " + str(e))
else:
bamru_event.gcal_id = None
Expand All @@ -86,7 +87,7 @@ def delete_for_event(self, bamru_event, save=True):
calendarId=self.calendar_id,
eventId=bamru_event.gcal_id,
).execute()
except GoogleAuthError as e:
except (googleapiclient.errors.HttpError, GoogleAuthError) as e:
logger.error("Gcal delete error " + str(e))
bamru_event.gcal_id = None

Expand Down Expand Up @@ -164,5 +165,5 @@ def get_gcal_manager(fallback_manager=NoopGcalManager()):
return fallback_manager

client = googleapiclient.discovery.build(
'calendar', 'v3', credentials=creds)
'calendar', 'v3', credentials=creds, cache_discovery=False)
return GcalManager(client, settings.GOOGLE_CALENDAR_ID)
2 changes: 1 addition & 1 deletion main/lib/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __new__(cls):
if not c:
return NoopGoogleDrive()
instance.drive = googleapiclient.discovery.build(
'drive', 'v3', credentials=c)
'drive', 'v3', credentials=c, cache_discovery=False)
if not instance.drive:
return NoopGoogleDrive()
return instance
Expand Down
2 changes: 1 addition & 1 deletion main/lib/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __new__(cls, name):
if not c:
return NoopGoogleGroup()
admin = googleapiclient.discovery.build(
'admin', 'directory_v1', credentials=c)
'admin', 'directory_v1', credentials=c, cache_discovery=False)
if not name or not admin:
return NoopGoogleGroup()
instance.members = admin.members()
Expand Down
2 changes: 2 additions & 0 deletions main/models/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def _google_profile_info(self):
return data

def profile_email_to_email_set(self):
if not self.profile_email:
return # Nothing to do
email = self.email_set.filter(address__iexact=self.profile_email)
if email:
email.pagable = True
Expand Down

0 comments on commit fad19d0

Please sign in to comment.