mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
Handle suspended users with calendar commands; improve show calsettings output (#369)
This commit is contained in:
29
src/gam.py
29
src/gam.py
@@ -972,7 +972,7 @@ def callGAPI(service, function,
|
|||||||
|
|
||||||
def callGAPIpages(service, function, items,
|
def callGAPIpages(service, function, items,
|
||||||
page_message=None, message_attribute=None,
|
page_message=None, message_attribute=None,
|
||||||
throw_reasons=None,
|
soft_errors=False, throw_reasons=None, retry_reasons=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
if throw_reasons is None:
|
if throw_reasons is None:
|
||||||
throw_reasons = []
|
throw_reasons = []
|
||||||
@@ -980,7 +980,7 @@ def callGAPIpages(service, function, items,
|
|||||||
all_pages = list()
|
all_pages = list()
|
||||||
total_items = 0
|
total_items = 0
|
||||||
while True:
|
while True:
|
||||||
this_page = callGAPI(service, function, throw_reasons=throw_reasons, pageToken=pageToken, **kwargs)
|
this_page = callGAPI(service, function, soft_errors=soft_errors, throw_reasons=throw_reasons, retry_reasons=retry_reasons, pageToken=pageToken, **kwargs)
|
||||||
if this_page:
|
if this_page:
|
||||||
pageToken = this_page.get(u'nextPageToken')
|
pageToken = this_page.get(u'nextPageToken')
|
||||||
if items in this_page:
|
if items in this_page:
|
||||||
@@ -2730,7 +2730,7 @@ def deleteCalendar(users):
|
|||||||
user, cal = buildCalendarGAPIObject(user)
|
user, cal = buildCalendarGAPIObject(user)
|
||||||
if not cal:
|
if not cal:
|
||||||
continue
|
continue
|
||||||
callGAPI(cal.calendarList(), u'delete', calendarId=calendarId)
|
callGAPI(cal.calendarList(), u'delete', soft_errors=True, calendarId=calendarId)
|
||||||
|
|
||||||
CALENDAR_REMINDER_METHODS = [u'email', u'sms', u'popup',]
|
CALENDAR_REMINDER_METHODS = [u'email', u'sms', u'popup',]
|
||||||
CALENDAR_NOTIFICATION_METHODS = [u'email', u'sms',]
|
CALENDAR_NOTIFICATION_METHODS = [u'email', u'sms',]
|
||||||
@@ -2829,7 +2829,7 @@ def addCalendar(users):
|
|||||||
if not cal:
|
if not cal:
|
||||||
continue
|
continue
|
||||||
print u"Subscribing %s to %s calendar (%s/%s)" % (user, calendarId, i, count)
|
print u"Subscribing %s to %s calendar (%s/%s)" % (user, calendarId, i, count)
|
||||||
callGAPI(cal.calendarList(), u'insert', body=body, colorRgbFormat=colorRgbFormat)
|
callGAPI(cal.calendarList(), u'insert', soft_errors=True, body=body, colorRgbFormat=colorRgbFormat)
|
||||||
|
|
||||||
def updateCalendar(users):
|
def updateCalendar(users):
|
||||||
buildGAPIObject(u'calendar')
|
buildGAPIObject(u'calendar')
|
||||||
@@ -2846,7 +2846,7 @@ def updateCalendar(users):
|
|||||||
if not cal:
|
if not cal:
|
||||||
continue
|
continue
|
||||||
print u"Updating %s's subscription to calendar %s (%s/%s)" % (user, calendarId, i, count)
|
print u"Updating %s's subscription to calendar %s (%s/%s)" % (user, calendarId, i, count)
|
||||||
callGAPI(cal.calendarList(), u'update', calendarId=calendarId, body=body, colorRgbFormat=colorRgbFormat)
|
callGAPI(cal.calendarList(), u'update', soft_errors=True, calendarId=calendarId, body=body, colorRgbFormat=colorRgbFormat)
|
||||||
|
|
||||||
def doPrinterShowACL():
|
def doPrinterShowACL():
|
||||||
cp = buildGAPIObject(u'cloudprint')
|
cp = buildGAPIObject(u'cloudprint')
|
||||||
@@ -3655,7 +3655,7 @@ def printShowCalendars(users, csvFormat):
|
|||||||
user, cal = buildCalendarGAPIObject(user)
|
user, cal = buildCalendarGAPIObject(user)
|
||||||
if not cal:
|
if not cal:
|
||||||
continue
|
continue
|
||||||
result = callGAPIpages(cal.calendarList(), u'list', u'items')
|
result = callGAPIpages(cal.calendarList(), u'list', u'items', soft_errors=True)
|
||||||
jcount = len(result)
|
jcount = len(result)
|
||||||
if not csvFormat:
|
if not csvFormat:
|
||||||
print u'User: {0}, Calendars: ({1}/{2})'.format(user, i, count)
|
print u'User: {0}, Calendars: ({1}/{2})'.format(user, i, count)
|
||||||
@@ -3676,13 +3676,21 @@ def printShowCalendars(users, csvFormat):
|
|||||||
writeCSVfile(csvRows, titles, u'Calendars', todrive)
|
writeCSVfile(csvRows, titles, u'Calendars', todrive)
|
||||||
|
|
||||||
def showCalSettings(users):
|
def showCalSettings(users):
|
||||||
|
i = 0
|
||||||
|
count = len(users)
|
||||||
for user in users:
|
for user in users:
|
||||||
|
i += 1
|
||||||
user, cal = buildCalendarGAPIObject(user)
|
user, cal = buildCalendarGAPIObject(user)
|
||||||
if not cal:
|
if not cal:
|
||||||
continue
|
continue
|
||||||
feed = callGAPI(cal.settings(), u'list')
|
feed = callGAPIpages(cal.settings(), u'list', u'items', soft_errors=True)
|
||||||
for setting in feed[u'items']:
|
if feed:
|
||||||
print u'%s: %s' % (setting[u'id'], setting[u'value'])
|
print u'User: {0}, Calendar Settings: ({1}/{2})'.format(user, i, count)
|
||||||
|
settings = {}
|
||||||
|
for setting in feed:
|
||||||
|
settings[setting[u'id']] = setting[u'value']
|
||||||
|
for attr, value in sorted(settings.items()):
|
||||||
|
print u' {0}: {1}'.format(attr, value)
|
||||||
|
|
||||||
def printDriveSettings(users):
|
def printDriveSettings(users):
|
||||||
todrive = False
|
todrive = False
|
||||||
@@ -4673,7 +4681,8 @@ def transferSecCals(users):
|
|||||||
user, source_cal = buildCalendarGAPIObject(user)
|
user, source_cal = buildCalendarGAPIObject(user)
|
||||||
if not source_cal:
|
if not source_cal:
|
||||||
continue
|
continue
|
||||||
source_calendars = callGAPIpages(source_cal.calendarList(), u'list', u'items', minAccessRole=u'owner', showHidden=True, fields=u'items(id),nextPageToken')
|
source_calendars = callGAPIpages(source_cal.calendarList(), u'list', u'items', soft_errors=True,
|
||||||
|
minAccessRole=u'owner', showHidden=True, fields=u'items(id),nextPageToken')
|
||||||
for source_cal in source_calendars:
|
for source_cal in source_calendars:
|
||||||
if source_cal[u'id'].find(u'@group.calendar.google.com') != -1:
|
if source_cal[u'id'].find(u'@group.calendar.google.com') != -1:
|
||||||
doCalendarAddACL(calendarId=source_cal[u'id'], act_as=user, role=u'owner', scope=u'user', entity=target_user)
|
doCalendarAddACL(calendarId=source_cal[u'id'], act_as=user, role=u'owner', scope=u'user', entity=target_user)
|
||||||
|
|||||||
Reference in New Issue
Block a user