diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 44df5cc0..2f774820 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,10 +10,15 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads-Installs](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads-Installs) for Windows or other options, including manual installation +### 6.80.06 + +Added option `tdreturnidonly []` to `` that when true (the default), causes GAM to display +only the uploaded file ID to stdout. This can be captured and used in subsequent commands, `tdfileid ` that will update the same file. + ### 6.80.05 Added option `individualstudentcoursework copy|delete|maptoall` to `gam create|update course ... copyfrom` -that controls how individual student course work in the `copyfrom` course is processed. +that controls how individual student coursework in the `copyfrom` course is processed. * `individualstudentcoursework copy` - Copy individual student coursework; this is the default. You will get an error if a student is not a member of the course * `individualstudentcoursework delete` - Delete individual student coursework * `individualstudentcoursework maptoall` - Map individual student coursework to all student coursework diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index 6f138eb2..8faeca78 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -251,7 +251,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin$ gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAMADV-XTD3 6.80.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.80.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -923,7 +923,7 @@ writes the credentials into the file oauth2.txt. C:\>del C:\GAMConfig\oauth2.txt C:\>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAMADV-XTD3 6.80.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.80.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Todrive.md b/docs/Todrive.md index eb4e3d67..104fe6bb 100644 --- a/docs/Todrive.md +++ b/docs/Todrive.md @@ -191,6 +191,7 @@ direct the uploaded file to a particular user and location and add a timestamp t (tdnotify [])| (tdparent (id:)|)| (tdretaintitle [])| + (tdreturnidonly [])| (tdshare commenter|reader|writer)*| (tdsheet (id:)|)| (tdsheettimestamp [] [tdsheettimeformat ]) @@ -238,6 +239,9 @@ If `tdfileid ` is not specified, a new file is created. * `tdcellwrap clip|overflow|wrap` - The Spreadsheet cell wrapping strategy. * `tdcellnumberformat text|number` - The Spreadsheet number format. +## Report action +* `tdreturnidonly` - If False, a message is written to stdout with the uploaded file URL; if True, only the uploaded file ID is written to stdout + ## Open browser and send email * `tdnobrowser` - If False, a browser is opened to view the file uploaded to Google Drive; if not specified, the `todrive_nobrowser` value from gam.cfg is used. If True, no browser is opened. * `tdnoemail` - If False, an email is sent to `tduser` informing them of name and URL of the uploaded file; if not specified, the `todrive_noemail` value from gam.cfg is used. If True, no email is sent to `tduser`. diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 8d378d48..9a408cfe 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -3,7 +3,7 @@ Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.80.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.80.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAMADV-XTD3 6.80.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.80.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second Print the current version of Gam with extended details and SSL information ``` gam version extended -GAMADV-XTD3 6.80.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.80.06 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 @@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gamadv-xtd3 Version Check: Current: 5.35.08 - Latest: 6.80.05 + Latest: 6.80.06 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.80.05 +6.80.06 ``` In Linux/MacOS you can do: ``` @@ -82,7 +82,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 6.80.05 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.80.06 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.4 64-bit final MacOS Sonoma 14.5 x86_64 diff --git a/src/GamCommands.txt b/src/GamCommands.txt index 60bad4f3..39f8b793 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -627,6 +627,7 @@ If an item contains spaces, it should be surrounded by ". (tdnotify [])| (tdparent (id:)|)| (tdretaintitle [])| + (tdreturnidonly [])| (tdshare commenter|reader|writer)*| (tdsheet (id:)|)| (tdsheettimestamp [] [tdsheettimeformat ]) diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 844576d6..f8903e33 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,10 +2,15 @@ Merged GAM-Team version +6.80.06 + +Added option `tdreturnidonly []` to `` that when true (the default), causes GAM to display +only the uploaded file ID to stdout. This can be captured and used in subsequent commands, `tdfileid ` that will update the same file. + 6.80.05 Added option `individualstudentcoursework copy|delete|maptoall` to `gam create|update course ... copyfrom` -that controls how individual student course work in the `copyfrom` course is processed. +that controls how individual student coursework in the `copyfrom` course is processed. * `individualstudentcoursework copy` - Copy individual student coursework; this is the default. You will get an error if a student is not a member of the course * `individualstudentcoursework delete` - Delete individual student coursework * `individualstudentcoursework maptoall` - Map individual student coursework to all student coursework diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 96b31774..7a91001f 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -7938,7 +7938,7 @@ class CSVPrintFile(): 'sheetdaysoffset': None, 'sheethoursoffset': None, 'fileId': None, 'parentId': None, 'parent': GC.Values[GC.TODRIVE_PARENT], 'retaintitle': False, 'localcopy': GC.Values[GC.TODRIVE_LOCALCOPY], 'uploadnodata': GC.Values[GC.TODRIVE_UPLOAD_NODATA], - 'nobrowser': GC.Values[GC.TODRIVE_NOBROWSER], 'noemail': GC.Values[GC.TODRIVE_NOEMAIL], + 'nobrowser': GC.Values[GC.TODRIVE_NOBROWSER], 'noemail': GC.Values[GC.TODRIVE_NOEMAIL], 'returnidonly': False, 'alert': [], 'share': [], 'notify': False, 'subject': None, 'from': None} while Cmd.ArgumentsRemaining(): myarg = getArgument() @@ -8009,6 +8009,8 @@ class CSVPrintFile(): self.todrive['nobrowser'] = getBoolean() elif myarg == 'tdnoemail': self.todrive['noemail'] = getBoolean() + elif myarg == 'tdreturnidonly': + self.todrive['returnidonly'] = getBoolean() elif myarg == 'tdnoescapechar': self.todrive['noescapechar'] = getBoolean() elif myarg == 'tdalert': @@ -8775,7 +8777,13 @@ class CSVPrintFile(): Act.Set(action) file_url = result['webViewLink'] msg_txt = f'{Msg.DATA_UPLOADED_TO_DRIVE_FILE}:\n{file_url}' - printKeyValueList([msg_txt]) + if not self.todrive['returnidonly']: + printKeyValueList([msg_txt]) + else: + if self.todrive['fileId']: + writeStdout(f'{self.todrive['fileId']}\n') + else: + writeStdout(f'{spreadsheetId}\n') if not self.todrive['subject']: subject = title else: @@ -75664,9 +75672,12 @@ def closeSTDFilesIfNotMultiprocessing(closeSTD): rdFd = GM.Globals[stdtype].get(GM.REDIRECT_FD) rdMultiFd = GM.Globals[stdtype].get(GM.REDIRECT_MULTI_FD) if rdFd and rdMultiFd and (rdFd == rdMultiFd) and (rdFd != stdfile): - rdFd.flush() - if closeSTD: - rdFd.close() + try: + rdFd.flush() + if closeSTD: + rdFd.close() + except BrokenPipeError: + pass closeSTDFile(GM.STDOUT, sys.stdout) if GM.Globals[GM.STDERR].get(GM.REDIRECT_NAME) != 'stdout':