From 3287a18cac311f67a943c1fdfc6031a7878aafb8 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Thu, 2 Aug 2018 16:27:34 -0700 Subject: [PATCH] Four fixes (#769) 1) Handle errors in gam-install.sh if user asks for unknown version 2) Over the last few days users get created but their org unit doesn't get assigned. If you say `gam ou /Path/To/Ou print users` you get a trap because you get a user with a primaryEmail and no orgUnitPath. 3) Make delete label take labels like all other label commands 4) Add data transfer service abbreviations like drive; this avoids an API call --- src/GamCommands.txt | 6 +++--- src/gam-install.sh | 14 ++++++++++++-- src/gam.py | 4 ++-- src/var.py | 3 +++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index d4be9d21..d993d0f8 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -189,7 +189,7 @@ If an item contains spaces, it should be surrounded by ". ::= See: https://developers.google.com/drive/v2/web/search-parameters ::= See: https://support.google.com/mail/answer/7190 ::= See: https://developers.google.com/admin-sdk/directory/v1/guides/search-groups - ::= See: https://support.google.com/a/answer/1408863?hl=en#search + ::= See: https://support.google.com/a/answer/7549103 ::= See: https://developers.google.com/cloud-print/docs/appInterfaces#search ::= See: https://developers.google.com/cloud-print/docs/appInterfaces#parameters_3 ::= See: https://developers.google.com/admin-sdk/directory/v1/guides/search-users @@ -838,7 +838,7 @@ gam update customer * gam info customer - ::= googledrive|gdrive|drive|"drive and docs"|calendar + ::= googledrive|gdrive|drive|"drive and docs"|calendar|gplus|google+|googleplus gam create datatransfer|transfer ( )* gam info datatransfer|transfer @@ -1009,7 +1009,7 @@ gam create verify|verification gam update verify|verification cname|txt|text|site|file gam info verify|verification -gam create course id|alias * +gam create course [id|alias ] * gam update course + gam delete course gam info course diff --git a/src/gam-install.sh b/src/gam-install.sh index 702c7e13..c440f28f 100755 --- a/src/gam-install.sh +++ b/src/gam-install.sh @@ -135,9 +135,11 @@ if type(release) is list: break try: for asset in release['assets']: - if asset[sys.argv[1]].endswith('$gamfile'): - print(asset[sys.argv[1]]) + if asset[attrib].endswith('$gamfile'): + print(asset[attrib]) break + else: + print('ERROR: Attribute: {0} for $gamfile version {1} not found'.format(attrib, gamversion)) except KeyError: print('ERROR: assets value not found in JSON value of:\n\n%s' % release)" @@ -155,7 +157,15 @@ if (( $rc != 0 )); then fi browser_download_url=$(echo "$release_json" | $pycmd -c "$pycode" browser_download_url $gamversion) +if [[ ${browser_download_url:0:5} = "ERROR" ]]; then + echo_red "${browser_download_url}" + exit +fi name=$(echo "$release_json" | $pycmd -c "$pycode" name $gamversion) +if [[ ${name:0:5} = "ERROR" ]]; then + echo_red "${name}" + exit +fi # Temp dir for archive #temp_archive_dir=$(mktemp -d) temp_archive_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') diff --git a/src/gam.py b/src/gam.py index 9b16cdb1..520de6cc 100755 --- a/src/gam.py +++ b/src/gam.py @@ -11679,7 +11679,7 @@ def getUsersToModify(entity_type=None, entity=None, silent=False, member_type=No query=query, maxResults=GC_Values[GC_USER_MAX_RESULTS]) ou = ou.lower() for member in members: - if (ou == member[u'orgUnitPath'].lower()) and not (checkNotSuspended and member[u'suspended']): + if (ou == member.get(u'orgUnitPath', u'').lower()) and not (checkNotSuspended and member[u'suspended']): users.append(member[u'primaryEmail']) if not silent: sys.stderr.write(u"%s Users are directly in the OU.\n" % len(users)) @@ -12824,7 +12824,7 @@ def ProcessGAMCommand(args): deleteDelegate(users) elif delWhat == u'calendar': deleteCalendar(users) - elif delWhat == u'label': + elif delWhat in [u'labels', u'label']: doDeleteLabel(users) elif delWhat in [u'message', u'messages']: runCmdForUsers(doProcessMessagesOrThreads, users, default_to_batch=True, function=u'delete', unit=u'messages') diff --git a/src/var.py b/src/var.py index 496ed0d1..6b975921 100644 --- a/src/var.py +++ b/src/var.py @@ -156,6 +156,9 @@ SERVICE_NAME_CHOICES_MAP = { u'googledrive': u'Drive and Docs', u'gdrive': u'Drive and Docs', u'calendar': u'Calendar', + u'gplus': u'Google+', + u'google+': u'Google+', + u'googleplus': u'Google+', } PRINTJOB_ASCENDINGORDER_MAP = {