From ab5aa02bf8856f7f18a3baa59e94a43c1a98b4fc Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Thu, 2 May 2024 15:14:11 -0700 Subject: [PATCH] Fixed bug in `gam batch|tbatch` --- docs/Bulk-Processing.md | 15 ++++++++++----- docs/GamUpdates.md | 7 +++++++ docs/How-to-Upgrade-from-Standard-GAM.md | 4 ++-- docs/Version-and-Help.md | 12 ++++++------ src/GamUpdate.txt | 7 +++++++ src/gam/__init__.py | 6 +++--- 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/docs/Bulk-Processing.md b/docs/Bulk-Processing.md index 9a19d819..cf9f8b35 100644 --- a/docs/Bulk-Processing.md +++ b/docs/Bulk-Processing.md @@ -42,6 +42,7 @@ Batch files can contain the following types of lines: * GAM prints \ and waits for the user to press any key * GAM continues * sleep \ - Batch processing will suspend for \ seconds before the next command line is processed + * To be effective, this should immediately follow commit-batch * print \ - Print \ on stderr * set \ \ * Subsequent lines will have %\% replaced with \ @@ -129,25 +130,29 @@ gam csv gsheet "" gam update user "~primaryEmail" add ## CSV files with redirection and select You should use the `multiprocess` option on any redirected files: `csv`, `stdout`, `stderr`. ``` -gam redirect csv ./filelistperms.csv multiprocess csv Users.csv gam user ~primaryEmail print filelist fields id,title,permissions,owners.emailaddress +gam redirect csv ./filelistperms.csv multiprocess csv Users.csv gam user ~primaryEmail print filelist fields id,name,mimetype,basicpermissions +gam redirect csv - multiprocess todrive csv Users.csv gam user ~primaryEmail print filelist fields id,name,mimetype,basicpermissions ``` If you want to select a `gam.cfg` section for the command, you can select the section at the outer `gam` and save it or select the section at the inner `gam`. ``` -gam select
save redirect csv ./filelistperms.csv multiprocess csv Users.csv gam user ~primaryEmail print filelist fields id,title,permissions,owners.emailaddress -gam redirect csv ./filelistperms.csv multiprocess csv Users.csv gam select
user ~primaryEmail print filelist fields id,title,permissions,owners.emailaddress +gam select
save redirect csv ./filelistperms.csv multiprocess csv Users.csv gam user ~primaryEmail print filelist fields id,name,mimetype,basicpermissions +gam redirect csv ./filelistperms.csv multiprocess csv Users.csv gam select
user ~primaryEmail print filelist fields id,name,mimetype,basicpermissions +gam select
save redirect csv - multiprocess todrive csv Users.csv gam user ~primaryEmail print filelist fields id,name,mimetype,basicpermissions +gam redirect csv - multiprocess todrive csv Users.csv gam select
user ~primaryEmail print filelist fields id,name,mimetype,basicpermissions ``` ## Automatic batch processing You can enable automatic batch (parallel) processing when issuing commands of the form `gam ...`. In the following example, if the number of users in group sales@domain.com exceeds 1, then the `print filelist` command will be processed in parallel. ``` -gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess group sales@domain.com print filelist fields id,title,permissions,owners.emailaddress +gam config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess group sales@domain.com print filelist fields id,name,mimetype,basicpermissions +gam config auto_batch_min 1 redirect csv - multiprocess todrive group sales@domain.com print filelist fields id,name,mimetype,basicpermissions ``` With automatic batch processing, you should use the `multiprocess` option on any redirected files: `csv`, `stdout`, `stderr`. If you want to select a `gam.cfg` section for the command, you must select and save it for it to be processed correctly. ``` -gam select
save config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess group sales@domain.com print filelist fields id,title,permissions,owners.emailaddress +gam select
save config auto_batch_min 1 redirect csv ./filelistperms.csv multiprocess group sales@domain.com print filelist fields id,name,mimetype,basicpermissions ``` diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 6d2f0c53..75a4f829 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,6 +10,13 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation +### 6.75.03 + +Fixed bug in `gam batch|tbatch` where the line `sleep ` in the batch file caused the error: +``` +ERROR: Invalid argument: Expected +``` + ### 6.75.02 Updated `gam report ` to retry/handle the following error: diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index fca4dfa5..c1188477 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -335,7 +335,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ ./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.75.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.75.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 x86_64 @@ -1009,7 +1009,7 @@ writes the credentials into the file oauth2.txt. C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAMADV-XTD3 6.75.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.75.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 2fdc8563..a550a1a5 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.75.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.75.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 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.75.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.75.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 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.75.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.75.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 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.75.02 + Latest: 6.75.03 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.75.02 +6.75.03 ``` 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.75.02 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.75.03 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 x86_64 diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 11d34e0f..1224e40f 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,13 @@ Merged GAM-Team version +6.75.03 + +Fixed bug in `gam batch|tbatch` where the line `sleep ` in the batch file caused the error: +``` +ERROR: Invalid argument: Expected +``` + 6.75.02 Updated `gam report ` to retry/handle the following error: diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 0b30db94..964967b9 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -9895,8 +9895,8 @@ def threadBatchWorker(showCmds=False, numItems=0): batchWriteStderr(f'{currentISOformatTimeStamp()},{pid}/{numItems},Error,{str(e)},{logCmd}\n') GM.Globals[GM.TBATCH_QUEUE].task_done() -BATCH_COMMANDS = [Cmd.GAM_CMD, Cmd.COMMIT_BATCH_CMD, Cmd.PRINT_CMD] -TBATCH_COMMANDS = [Cmd.GAM_CMD, Cmd.COMMIT_BATCH_CMD, Cmd.EXECUTE_CMD, Cmd.PRINT_CMD] +BATCH_COMMANDS = [Cmd.GAM_CMD, Cmd.COMMIT_BATCH_CMD, Cmd.PRINT_CMD, Cmd.SLEEP_CMD] +TBATCH_COMMANDS = [Cmd.GAM_CMD, Cmd.COMMIT_BATCH_CMD, Cmd.EXECUTE_CMD, Cmd.PRINT_CMD, Cmd.SLEEP_CMD] def ThreadBatchGAMCommands(items, showCmds): if not items: @@ -9934,7 +9934,7 @@ def ThreadBatchGAMCommands(items, showCmds): batchWriteStderr(f'{currentISOformatTimeStamp()},0/{numItems},{Cmd.QuotedArgumentList(item[1:])}\n') continue if item[0] == Cmd.SLEEP_CMD: - batchWriteStderr(f'{currentISOformatTimeStamp()},0/{numItems},Sleepiing {item[1]} seconds\n') + batchWriteStderr(f'{currentISOformatTimeStamp()},0/{numItems},Sleeping {item[1]} seconds\n') time.sleep(int(item[1])) continue pid += 1