From 05cbe1c6f3581aaae65981db341c5245baf3e7b8 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Mon, 8 Apr 2019 15:49:47 -0700 Subject: [PATCH] Update GamCommands.txt and Improve error message in get drivefile (#875) * Update GamCommands.txt * Improve error message when trying to dowload files * Update GamCommands.txt --- src/GamCommands.txt | 41 +++++++++++++++++++++++------------------ src/gam.py | 12 ++++++++++-- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 67da7f97..82fca57b 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -775,38 +775,43 @@ Specify a collection of Users by directly specifying them or by specifiying item ::= field (type bool|date|double|email|int64|phone|string) [multivalued|multivalue] [indexed] [restricted] [range ] endfield - ::= - (address clear|(type work|home|other|(custom ) [unstructured|formatted ] [pobox ] [extendedaddress ] [streetaddress ] - [locality ] [region ] [postalcode ] [country ] [countrycode ] notprimary|primary))| + ::= (agreed2terms|agreedtoterms )| (changepassword|changepasswordatnextlogin )| (crypt|sha|sha1|sha-1|md5|nohash)| (customerid )| (email|primaryemail|username )| - (otheremail clear|(work|home|other| ))| - (externalid clear|(account|customer|login_id|network|organization| ))| (firstname|givenname )| (gal|includeinglobaladdresslist )| (gender clear|(female|male|unknown|(other ) [addressmeas ]))| - (im clear|(type work|home|other|(custom ) protocol aim|gtalk|icq|jabber|msn|net_meeting|qq|skype|yahoo|(custom_protocol ) [notprimary|primary]))| (ipwhitelisted )| - (keyword clear|(occupation|outlook|(custom ) ))| (language clear|)| (lastname|familyname )| - (location clear|(type default|desk| area [building|buildingid ] [floor|floorname ] [section|floorsection ] [desk|deskcode ] endlocation))| - (note clear|([text_plain|text_html] |(file [charset ])))| - (organization clear|([type domain_only|school|unknown|work] [customtype ] [name ] [title ] [department ] [symbol ] - [costcenter ] [location ] [description ] [domain ] notprimary|primary))| + (note clear|([text_html|text_plain] |(file [charset ])))| (org|ou|orgunitpath ) (password random|)| - (phone clear|([type work|home|other|work_fax|home_fax|other_fax|main|company_main|assistant|mobile|work_mobile|pager|work_pager|car|radio|callback|isdn|telex|tty_tdd|grand_central|(custom )] - [value ] notprimary|primary))| - (posix clear|(username uid gid [system|systemid ] [home|homedirectory ] [shell ] [gecos ] [primary ] endposix))| - (relation clear|(spouse|child|mother|father|parent|brother|sister|friend|relative|domestic_partner|manager|dotted-line_manager|assistant|admin_assistant|exec_assistant|referred_by|partner| ))| - (sshkeys clear|(key [expires ] endssh))| (suspended )| - (website clear|(home_page|blog|profile|work|home|other|ftp|reservations|app_install_page| [notprimary|primary]))| - (. [multivalued|multivalue|value|multinonempty [type work|home|other|(custom )]] ) + (. [multivalued|multivalue|value|multinonempty [type home|other|work|(custom )]] ) + ::= + (address clear|(type home|other|work|(custom ) [unstructured|formatted ] [pobox ] [extendedaddress ] [streetaddress ] + [locality ] [region ] [postalcode ] [country ] [countrycode ] notprimary|primary))| + (otheremail clear|(home|other|work| ))| + (externalid clear|(account|customer|login_id|network|organization| ))| + (im clear|(type home|other|work|(custom ) protocol aim|gtalk|icq|jabber|msn|net_meeting|qq|skype|yahoo|(custom_protocol ) [notprimary|primary]))| + (keyword clear|(mission|occupation|outlook|(custom ) ))| + (location clear|(type default|desk| area [building|buildingid ] [floor|floorname ] [section|floorsection ] [desk|deskcode ] endlocation))| + (organization clear|([type domain_only|school|unknown|work] [customtype ] [name ] [title ] [department ] [symbol ] + [costcenter ] [location ] [description ] [domain ] [fulltimeequivalent ] notprimary|primary))| + (phone clear|([type assistant|callback|car|company_main|grand_central|home|home_fax|isdn|main|mobile|other|other_fax|pager|radio|telex|tty_tdd|work|work_fax|work_mobile|work_pager|(custom )] + [value ] notprimary|primary))| + (posix clear|(username uid gid [system|systemid ] [home|homedirectory ] [shell ] + [gecos ] [os|operatingSystemType linux|unspecified|windows] [primary ] endposix))| + (relation clear|(admin_assistant|assistant|brother|child|domestic_partner|dotted-line_manager|exec_assistant|father|friend|manager|mother|parent|partner|referred_by|relative|sister|spouse| ))| + (sshkeys clear|(key [expires ] endssh))| + (website clear|(app_install_page|blog|ftp|home|home_page|other|profile|reservations|resume|work| [notprimary|primary])) + ::= + | + gam version [check] [simple] gam help diff --git a/src/gam.py b/src/gam.py index 0f10ef67..cf0de6f5 100755 --- a/src/gam.py +++ b/src/gam.py @@ -4665,6 +4665,8 @@ def createDriveFile(users): if csv_output: writeCSVfile(csv_rows, csv_titles, u'Files', to_drive) +HTTP_ERROR_PATTERN = re.compile(r'^.*returned "(.*)">$') + def downloadDriveFile(users): i = 5 fileIdSelection = {u'fileIds': [], u'query': None} @@ -4838,8 +4840,14 @@ def downloadDriveFile(users): GM_Globals[GM_SYSEXITRC] = 6 fileDownloadFailed = True break - except googleapiclient.http.HttpError: - sys.stderr.write(u'Format ({0}) not available\n'.format(extension[1:])) + except googleapiclient.http.HttpError as e: + mg = HTTP_ERROR_PATTERN.match(str(e)) + if mg: + stderrErrorMsg(mg.group(1)) + else: + stderrErrorMsg(str(e)) + fileDownloadFailed = True + break if fh and not targetStdout: closeFile(fh) os.remove(filename)