From 29792677d71b5538e37753d5578df88f556e7101 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 22 May 2024 13:18:02 -0700 Subject: [PATCH] Added option `showusagebytes` to `gam print|show drivesettings` --- docs/Drive-File-Selection.md | 2 +- docs/GamUpdates.md | 7 ++++++ docs/How-to-Upgrade-from-Standard-GAM.md | 4 ++-- docs/Users-Drive-Activity-Settings.md | 10 +++++++-- docs/Version-and-Help.md | 14 ++++++------ src/GamCommands.txt | 8 +++++-- src/GamUpdate.txt | 7 ++++++ src/gam/__init__.py | 28 +++++++++++++++++++++--- 8 files changed, 63 insertions(+), 17 deletions(-) diff --git a/docs/Drive-File-Selection.md b/docs/Drive-File-Selection.md index 72807356..bb7f96b3 100644 --- a/docs/Drive-File-Selection.md +++ b/docs/Drive-File-Selection.md @@ -182,7 +182,7 @@ gam user testuser show fileinfo anydrivefilename "Test File" gam user testuser show fileinfo anydrivefilename:"Test File" ``` ## Select file ownership -By default, files the user owns are sisplayed; you can select the ownership characteristic. +By default, files the user owns are displayed; you can select the ownership characteristic. ``` anyowner|(showownedby any|me|others) ``` diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 92e33ccd..de9576a3 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.76.06 + +Added option `showusagebytes` to `gam print|show drivesettings` that displays +the following fields in bytes ```usageBytes,usageInDriveBytes,usageInDriveTrashBytes``` +in addition to the fields in their formatted form with units: ```usage,usageInDrive,usageInDriveTrash```. +This will be most useful with `print` as the rows can be sorted based on the `usagexxxBytes` columns. + ### 6.76.05 Added options `deletefromoldowner`, `addtonewowner *` and `nolistmessages` diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index 836a6210..e174244d 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.76.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.06 - 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.76.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.06 - 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/Users-Drive-Activity-Settings.md b/docs/Users-Drive-Activity-Settings.md index 463c1af1..42f881ff 100644 --- a/docs/Users-Drive-Activity-Settings.md +++ b/docs/Users-Drive-Activity-Settings.md @@ -141,10 +141,16 @@ The `quotechar ` option allows you to choose an alternate quote chara ``` gam print drivesettings [todrive *] [allfields|*|(fields )] - [delimiter ] + [delimiter ] [showusagebytes] gam show drivesettings [allfields|*|(fields )] - [delimiter ] + [delimiter ] [showusagebytes] ``` If no fields are selected, these fields will be displayed: `name,appInstalled,largestChangeId,limit,maxUploadSize,permissionId,rootFolderId,usage,usageInDrive,usageInDriveTrash` + +By default, these fields are displayed in formatted form with units: ```usage,usageInDrive,usageInDriveTrash```. + +The option `showusagebytes` also displays the following fields in bytes ```usageBytes,usageInDriveBytes,usageInDriveTrashBytes```. + +This will be most useful with `print` as the rows can be sorted based on the `usagexxxBytes` columns. diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index 3714ba8b..00c734fe 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -1,9 +1,9 @@ -# Version and Help +\# Version and Help Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.76.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.06 - 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.76.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.06 - 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.76.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.06 - 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.76.05 + Latest: 6.76.06 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.76.05 +6.76.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.76.05 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.76.06 - 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/GamCommands.txt b/src/GamCommands.txt index 9dd49fc8..5ce3f9a1 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -6904,8 +6904,12 @@ gam print|show driveactivity [todrive *] usageindrivetrash ::= "(,)*" -gam print drivesettings [todrive *] [allfields|*|(fields )] [delimiter ] -gam show drivesettings [allfields|*|(fields )] [delimiter ] +gam print drivesettings [todrive *] + [allfields|*|(fields )] + [delimiter ] [showusagebytes] +gam show drivesettings + [allfields|*|(fields )] + [delimiter ] [showusagebytes] gam print emptydrivefolders [todrive *] [select ] diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index f18a7709..22c0c56d 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,13 @@ Merged GAM-Team version +6.76.06 + +Added option `showusagebytes` to `gam print|show drivesettings` that displays +the following fields in bytes ```usageBytes,usageInDriveBytes,usageInDriveTrashBytes``` +in addition to the fields in their formatted form with units: ```usage,usageInDrive,usageInDriveTrash```. +This will be most useful with `print` as the rows can be sorted based on the `usagexxxBytes` columns. + 6.76.05 Added options `deletefromoldowner`, `addtonewowner *` and `nolistmessages` diff --git a/src/gam/__init__.py b/src/gam/__init__.py index abcb5f5a..c4d6c1ea 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -51424,6 +51424,12 @@ DRIVESETTINGS_SCALAR_FIELDS = [ 'usageInDriveTrash', ] +DRIVESETTINGS_USAGE_BYTES_FIELDS = { + 'usage': 'usageBytes', + 'usageInDrive': 'usageInDriveBytes', + 'usageInDriveTrash': 'usageInDriveTrashBytes', + } + def _showSharedDriveThemeSettings(themes): Ind.Increment() for theme in themes: @@ -51435,9 +51441,11 @@ def _showSharedDriveThemeSettings(themes): Ind.Decrement() # gam print drivesettings [todrive *] -# [allfields|*|(fields )] [delimiter ] +# [allfields|*|(fields )] +# [delimiter ] [showusagebytes] # gam show drivesettings -# [allfields|*|(fields )] [delimiter ] +# [allfields|*|(fields )] +# [delimiter ] [showusagebytes] def printShowDriveSettings(users): def _showFormats(title): if title in fieldsList and title in feed: @@ -51473,6 +51481,7 @@ def printShowDriveSettings(users): csvPF = CSVPrintFile(['email'], ['email']+DRIVESETTINGS_SCALAR_FIELDS) if Act.csvFormat() else None fieldsList = [] delimiter = GC.Values[GC.CSV_OUTPUT_FIELD_DELIMITER] + showUsageBytes = False while Cmd.ArgumentsRemaining(): myarg = getArgument() if csvPF and myarg == 'todrive': @@ -51483,6 +51492,8 @@ def printShowDriveSettings(users): fieldsList.extend(DRIVESETTINGS_FIELDS_CHOICE_MAP.values()) elif getFieldsList(myarg, DRIVESETTINGS_FIELDS_CHOICE_MAP, fieldsList): pass + elif myarg == 'showusagebytes': + showUsageBytes = True else: unknownArgumentExit() if not fieldsList: @@ -51507,7 +51518,10 @@ def printShowDriveSettings(users): else: feed['limit'] = 'UNLIMITED' for setting in ['usage', 'usageInDrive', 'usageInDriveTrash']: - feed[setting] = formatFileSize(int(feed['storageQuota'].get(setting, '0'))) + uval = int(feed['storageQuota'].get(setting, '0')) + feed[setting] = formatFileSize(uval) + if showUsageBytes: + feed[DRIVESETTINGS_USAGE_BYTES_FIELDS[setting]] = uval if 'rootFolderId' in fieldsList: feed['rootFolderId'] = callGAPI(drive.files(), 'get', throwReasons=GAPI.DRIVE_USER_THROW_REASONS, @@ -51521,6 +51535,10 @@ def printShowDriveSettings(users): Ind.Increment() for setting in DRIVESETTINGS_SCALAR_FIELDS: _showSetting(setting) + if showUsageBytes: + for title, setting in DRIVESETTINGS_USAGE_BYTES_FIELDS.items(): + if title in fieldsList and setting in feed: + printKeyValueList([setting, feed[setting]]) _showSetting('folderColorPalette') _showFormats('exportFormats') _showFormats('importFormats') @@ -51538,6 +51556,10 @@ def printShowDriveSettings(users): row = {'email': user} for setting in DRIVESETTINGS_SCALAR_FIELDS: _addSetting(row, setting) + if showUsageBytes: + for title, setting in DRIVESETTINGS_USAGE_BYTES_FIELDS.items(): + if title in fieldsList and setting in feed: + row[setting] = feed[setting] _addSetting(row, 'folderColorPalette') _addFormats(row, 'exportFormats') _addFormats(row, 'importFormats')