From dcaf892e95181c75ae2634acd26ffe8a6ca66591 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Tue, 6 Feb 2024 18:20:54 -0800 Subject: [PATCH] Added option `wait ` to `gam create datatransfer` --- docs/GamUpdates.md | 7 ++++++ docs/Google-Data-Transfers.md | 5 +++++ docs/How-to-Upgrade-from-Standard-GAM.md | 4 ++-- docs/Version-and-Help.md | 12 +++++------ src/GamCommands.txt | 8 +++---- src/GamUpdate.txt | 7 ++++++ src/gam/__init__.py | 27 ++++++++++++++++++++++++ 7 files changed, 58 insertions(+), 12 deletions(-) diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index af148998..fd311d56 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -11,6 +11,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.67.39 + +Added option `wait ` to `gam create datatransfer` that causes GAM to wait +for the transfer to complete. The first `` must be in the range 5-60 and is the number +of seconds between checks to see if the transfer has completed. The second `` is the maximum +number of checks to perform. By default, GAM does not wait for the transfer to complete. + ### 6.67.38 Added option `tdnotify []` to `` that causes GAM to send notification diff --git a/docs/Google-Data-Transfers.md b/docs/Google-Data-Transfers.md index 4c459429..a1d59201 100644 --- a/docs/Google-Data-Transfers.md +++ b/docs/Google-Data-Transfers.md @@ -37,6 +37,7 @@ gam create|add datatransfer|transfer ]] ( )* + [wait ] ``` For`datastudio` and `drive`, there are options to control the privacy level of the files to be transferred. * `private` or `privacy_level private` - Transfer files that are not shared with anyone @@ -54,6 +55,10 @@ As of 2020-06-10, background transfers only transfer future non-private events w The option ` ` is for future expansion. +By default, GAM does not wait for the transfer to complete. The option `wait ` causes GAM to wait +for the transfer to complete. The first `` must be in the range 5-60 and is the number +of seconds between checks to see if the transfer has completed. The second `` is the maximum number of checks to perform. + ## Display transfers ``` gam info datatransfer|transfer diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index 75657852..b33b52dd 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -334,7 +334,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.67.38 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.39 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.1 x86_64 @@ -1002,7 +1002,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.67.38 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.39 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index b02d6712..7dc74b48 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.67.38 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.39 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.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.67.38 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.39 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.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.67.38 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.67.39 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.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.67.38 + Latest: 6.67.39 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.67.38 +6.67.39 ``` 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.67.38 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.67.39 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.1 64-bit final MacOS Sonoma 14.2.1 x86_64 diff --git a/src/GamCommands.txt b/src/GamCommands.txt index c1058dd2..e454c4ad 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -3142,7 +3142,7 @@ gam print|show transferapps gam create|add datatransfer|transfer [private|shared|all] [release_resources] ( )* - + [wait ] gam info datatransfer|transfer gam print datatransfers|transfers [todrive *] [olduser|oldowner ] [newuser|newowner ] @@ -3363,16 +3363,16 @@ gam show peoplecontacts [allfields|(fields )] [showmetadata] [formatjson] -gam info people +gam info people|peopleprofile [allfields|(fields )] [showmetadata] [formatjson] -gam print people [todrive *] +gam print people|peopleprofile [todrive *] [query ] [mergesources ] [coountsonly] [allfields|(fields )] [showmetadata] [formatjson [quotechar ]] -gam show people +gam show people|peopleprofile [query ] [mergesources ] [coountsonly] diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index dc39aa84..14545377 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,13 @@ Merged GAM-Team version +6.67.39 + +Added option `wait ` to `gam create datatransfer` that causes GAM to wait +for the transfer to complete. The first `` must be in the range 5-60 and is the number +of seconds between checks to see if the transfer has completed. The second `` is the maximum +number of checks to perform. By default, GAM does not wait for the transfer to complete. + 6.67.38 Added option `tdnotify []` to `` that causes GAM to send notification diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 099b74f2..bb9538d4 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -16351,6 +16351,7 @@ PRIVACY_LEVEL_CHOICE_MAP = { # gam create datatransfer|transfer # [private|shared|all] [release_resources] ( )* +# [wait ] def doCreateDataTransfer(): def _assignAppParameter(key, value, doubleBackup=False): keyValid = False @@ -16375,6 +16376,7 @@ def doCreateDataTransfer(): body = {'oldOwnerUserId': convertEmailAddressToUID(old_owner)} appIndicies = {} appNameList = [] + waitInterval = waitRetries = 0 i = 0 body['applicationDataTransfers'] = [] for appName in getString(Cmd.OB_SERVICE_NAME_LIST).split(','): @@ -16395,6 +16397,9 @@ def doCreateDataTransfer(): elif myarg == 'releaseresources': if getBoolean(): _assignAppParameter('RELEASE_RESOURCES', ['TRUE']) + elif myarg == 'wait': + waitInterval = getInteger(minVal=5, maxVal=60) + waitRetries = getInteger(minVal=0) else: _assignAppParameter(Cmd.Previous().upper(), getString(Cmd.OB_PARAMETER_VALUE).upper().split(','), True) try: @@ -16410,6 +16415,28 @@ def doCreateDataTransfer(): printKeyValueList([Msg.FROM, old_owner]) printKeyValueList([Msg.TO, new_owner]) Ind.Decrement() + if waitRetries == 0: + return + retry = 0 + status = 'inProgress' + dtId = result['id'] + while True: + writeStderr(Ind.Spaces()+Msg.WAITING_FOR_DATA_TRANSFER_TO_COMPLETE_SLEEPING.format(waitInterval)) + time.sleep(waitInterval) + try: + result = callGAPI(dt.transfers(), 'get', + throwReasons=[GAPI.NOT_FOUND], + dataTransferId=dtId, fields='overallTransferStatusCode') + if result['overallTransferStatusCode'] == 'completed': + status = result['overallTransferStatusCode'] + break + retry += 1 + if retry >= waitRetries: + break + except GAPI.notFound: + entityActionFailedWarning([Ent.TRANSFER_ID, dtId], Msg.DOES_NOT_EXIST) + break + printEntity([Ent.TRANSFER_ID, dtId, Ent.STATUS, status]) def _showTransfer(apps, transfer, i, count): printEntity([Ent.TRANSFER_ID, transfer['id']], i, count)