Added option sizefield quotabytesused|size to file display commands

Fixed bug in gam <UserTypeEntity> copy|move drivefile` that caused a trap.
This commit is contained in:
Ross Scroggs
2023-11-22 08:56:30 -08:00
parent 7cfb16c1f5
commit 51de288f27
7 changed files with 162 additions and 54 deletions

View File

@@ -10,6 +10,28 @@ 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.65.14
Fixed bug in gam <UserTypeEntity> copy|move drivefile` that caused a trap.
```
UnboundLocalError: cannot access local variable 'emailAddress' where it is not associated with a value
```
### 6.65.13
Added support for user language `en-CA`.
Added option `sizefield quotabytesused|size` to the following commands that specifies which
file size field to use when totaling file sizes; the default value is `quotabytesused`; previous versions used `size`.
```
gam <UserTypeEntity> print|show filecounts
gam <UserTypeEntity> print filelist
gam <UserTypeEntity> print|show filetree
gam <UserTypeEntity> print diskusage
```
See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Files-Display#file-size-fields
### 6.65.12
Additional updates on MacOS when a `gam csv` command is interrupted with a contol-C.

View File

@@ -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.65.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.65.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.10.8 64-bit final
MacOS High Sierra 10.13.6 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.65.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.65.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
Windows-10-10.0.17134 AMD64

View File

@@ -5,6 +5,7 @@
- [Permission Matches](Permission-Matches)
- [Definitions](#definitions)
- [Return Codes](#return-codes)
- [File size fields](#file-size-fields)
- [Display file information](#display-file-information)
- [Display file paths](#display-file-paths)
- [Select files for Display file counts, list, tree](#select-files-for-display-file-counts-list-tree)
@@ -358,6 +359,29 @@ $ echo $?
60
```
## File size fields
The Drive API defines two fields that relate to file size: `quotaBytesUsed` and `size`.
```
quotaBytesUsed - The number of storage quota bytes used by the file.
This includes the head revision as well as previous revisions with keepForever enabled.
size - Size in bytes of blobs and first party editor files.
```
Previously, GAM used the `size` field when totaling file sizes, it now uses the `quotaBytesUsed` field.
The option `sizefield quotabytesused|size` allows you to select which field to use.
For most MIME types, the values are the same; for the following MIME types, `quotabytesused` is larger.
```
application/pdf
application/vnd.ms-powerpoint
application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/zip
audio/mpeg
image/jpeg
image/png
```
## Display file information
Display file details in indented keyword: value format. The two forms are equivalent.
```
@@ -617,7 +641,8 @@ gam <UserTypeEntity> print filecounts [todrive <ToDriveAttribute>*]
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -629,7 +654,8 @@ gam <UserTypeEntity> show filecounts
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -860,7 +886,8 @@ gam <UserTypeEntity> print filetree [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -871,7 +898,8 @@ gam <UserTypeEntity> show filetree
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -929,12 +957,14 @@ gam <UserTypeEntity> print|show filelist [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[(norecursion [<Boolean>])|(depth <Number>)] [showparent]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>] [pmfilter] [oneitemperrow]
[excludetrashed]
[maxfiles <Integer>] [nodataheaders <String>]
[countsonly [summary none|only|plus] [summaryuser <String>] [showsource] [showsize] [showmimetypesize]] [countsrowfilter]
[countsonly [summary none|only|plus] [summaryuser <String>]
[showsource] [showsize] [showmimetypesize]] [countsrowfilter]
[filepath|fullpath [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
[showdrivename] [showshareddrivepermissions]
@@ -1442,6 +1472,7 @@ BadNews-NoData
```
gam <UserTypeEntity> print diskusage <DriveFileEntity> [todrive <ToDriveAttribute>*]
[anyowner|(showownedby any|me|others)]
[sizefield quotabytesused|size]
[pathdelimiter <Character>] [excludetrashed] [stripcrsfromname]
(addcsvdata <FieldName> <String>)*
[noprogress] [show all|summary|summaryandtrash]

View File

@@ -4,7 +4,7 @@
Print the current version of Gam with details
```
gam version
GAMADV-XTD3 6.65.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.65.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64
@@ -16,7 +16,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.65.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.65.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64
@@ -28,7 +28,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.65.12 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
GAMADV-XTD3 6.65.14 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64
@@ -65,7 +65,7 @@ MacOS High Sierra 10.13.6 x86_64
Path: /Users/Admin/bin/gamadv-xtd3
Version Check:
Current: 5.35.08
Latest: 6.65.12
Latest: 6.65.14
echo $?
1
```
@@ -73,7 +73,7 @@ echo $?
Print the current version number without details
```
gam version simple
6.65.12
6.65.14
```
In Linux/MacOS you can do:
```
@@ -83,7 +83,7 @@ echo $VER
Print the current version of Gam and address of this Wiki
```
gam help
GAM 6.65.12 - https://github.com/taers232c/GAMADV-XTD3
GAM 6.65.14 - https://github.com/taers232c/GAMADV-XTD3
Ross Scroggs <ross.scroggs@gmail.com>
Python 3.12.0 64-bit final
MacOS Monterey 12.7 x86_64

View File

@@ -125,7 +125,7 @@ If an item contains spaces, it should be surrounded by ".
#7a4706|#8a1c0a|#994a64|#ffffff
<LanguageCode> ::=
ach|af|ag|ak|am|ar|az|be|bem|bg|bn|br|bs|ca|chr|ckb|co|crs|cs|cy|da|de|
ee|el|en|en-gb|en-us|eo|es|es-419|et|eu|fa|fi|fil|fo|fr|fr-ca|fy|
ee|el|en|en-ca|en-gb|en-us|eo|es|es-419|et|eu|fa|fi|fil|fo|fr|fr-ca|fy|
ga|gaa|gd|gl|gn|gu|ha|haw|he|hi|hr|ht|hu|hy|ia|id|ig|in|is|it|iw|ja|jw|
ka|kg|kk|km|kn|ko|kri|ku|ky|la|lg|ln|lo|loz|lt|lua|lv|
mfe|mg|mi|mk|ml|mn|mo|mr|ms|mt|my|ne|nl|nn|no|nso|ny|nyn|oc|om|or|
@@ -6488,7 +6488,8 @@ gam <UserTypeEntity> print filecounts [todrive <ToDriveAttribute>*]
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -6500,7 +6501,8 @@ gam <UserTypeEntity> show filecounts
[corpora <CorporaAttribute>]
[select <SharedDriveEntity>]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -6531,7 +6533,8 @@ gam <UserTypeEntity> print filetree [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -6542,7 +6545,8 @@ gam <UserTypeEntity> show filetree
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[depth <Number>]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
[excludetrashed]
@@ -6558,12 +6562,15 @@ gam <UserTypeEntity> print filelist [todrive <ToDriveAttribute>*]
[select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
[(norecursion [<Boolean>])|(depth <Number>)] [showparent]]
[anyowner|(showownedby any|me|others)]
[showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[showmimetype [not] <MimeTypeList>]
[sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
[filenamematchpattern <RegularExpression>]
<PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>] [pmfilter] [oneitemperrow]
[excludetrashed]
[maxfiles <Integer>] [nodataheaders <String>]
[countsonly [summary none|only|plus] [summaryuser <String>] [showsource] [showsize] [showmimetypesize]] [countsrowfilter]
[countsonly [summary none|only|plus] [summaryuser <String>]
[showsource] [showsize] [showmimetypesize]]
[countsrowfilter]
[filepath|fullpath [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
[showdrivename] [showshareddrivepermissions]
@@ -6576,6 +6583,7 @@ gam <UserTypeEntity> print filelist [todrive <ToDriveAttribute>*]
gam <UserTypeEntity> print diskusage <DriveFileEntity> [todrive <ToDriveAttribute>*]
[anyowner|(showownedby any|me|others)]
[sizefield quotabytesused|size]
[pathdelimiter <Character>] [excludetrashed] [stripcrsfromname]
(addcsvdata <FieldName> <String>)*
[noprogress] [show all|summary|summaryandtrash]

View File

@@ -2,6 +2,27 @@
Merged GAM-Team version
6.65.14
Fixed bug in gam <UserTypeEntity> copy|move drivefile` that caused a trap.
```
UnboundLocalError: cannot access local variable 'emailAddress' where it is not associated with a value
```
6.65.13
Added support for user language `en-CA`.
Added option `sizefield quotabytesused|size` to the following commands that specifies which
file size field to use when totaling file sizes; the default value is `quotabytesused`; previous versions used `size`.
```
gam <UserTypeEntity> print|show filecounts
gam <UserTypeEntity> print filelist
gam <UserTypeEntity> print|show filetree
gam <UserTypeEntity> print diskusage
```
See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Files-Display#file-size-fields
6.65.12
Additional updates on MacOS when a `gam csv` command is interrupted with a contol-C.

View File

@@ -1101,7 +1101,7 @@ LANGUAGE_CODES_MAP = {
'ach': 'ach', 'af': 'af', 'ag': 'ga', 'ak': 'ak', 'am': 'am', 'ar': 'ar', 'az': 'az', #Luo, Afrikaans, Irish, Akan, Amharic, Arabica, Azerbaijani
'be': 'be', 'bem': 'bem', 'bg': 'bg', 'bn': 'bn', 'br': 'br', 'bs': 'bs', 'ca': 'ca', #Belarusian, Bemba, Bulgarian, Bengali, Breton, Bosnian, Catalan
'chr': 'chr', 'ckb': 'ckb', 'co': 'co', 'crs': 'crs', 'cs': 'cs', 'cy': 'cy', 'da': 'da', #Cherokee, Kurdish (Sorani), Corsican, Seychellois Creole, Czech, Welsh, Danish
'de': 'de', 'ee': 'ee', 'el': 'el', 'en': 'en', 'en-gb': 'en-GB', 'en-us': 'en-US', 'eo': 'eo', #German, Ewe, Greek, English, English (UK), English (US), Esperanto
'de': 'de', 'ee': 'ee', 'el': 'el', 'en': 'en', 'en-ca': 'en-CA', 'en-gb': 'en-GB', 'en-us': 'en-US', 'eo': 'eo', #German, Ewe, Greek, English, English (CA), English (UK), English (US), Esperanto
'es': 'es', 'es-419': 'es-419', 'et': 'et', 'eu': 'eu', 'fa': 'fa', 'fi': 'fi', 'fil': 'fil', 'fo': 'fo', #Spanish, Spanish (Latin American), Estonian, Basque, Persian, Finnish, Filipino, Faroese
'fr': 'fr', 'fr-ca': 'fr-CA', 'fy': 'fy', 'ga': 'ga', 'gaa': 'gaa', 'gd': 'gd', 'gl': 'gl', #French, French (Canada), Frisian, Irish, Ga, Scots Gaelic, Galician
'gn': 'gn', 'gu': 'gu', 'ha': 'ha', 'haw': 'haw', 'he': 'he', 'hi': 'hi', 'hr': 'hr', #Guarani, Gujarati, Hausa, Hawaiian, Hebrew, Hindi, Croatian
@@ -9564,7 +9564,8 @@ def MultiprocessGAMCommands(items, showCmds):
parallelPoolProcesses = numPoolProcesses
else:
parallelPoolProcesses = min(numItems, GC.Values[GC.MULTIPROCESS_POOL_LIMIT])
origSigintHandler = signal.signal(signal.SIGINT, signal.SIG_IGN)
# origSigintHandler = signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGINT, signal.SIG_IGN)
mpManager = multiprocessing.Manager()
l = mpManager.Lock()
try:
@@ -52145,8 +52146,8 @@ class DriveListParameters():
def CheckMimeType(self, fileInfo):
return self.mimeTypeCheck.Check(fileInfo)
def CheckFileSize(self, fileInfo):
size = int(fileInfo.get('size', '0'))
def CheckFileSize(self, fileInfo, sizeField):
size = int(fileInfo.get(sizeField, '0'))
if self.minimumFileSize is not None and size < self.minimumFileSize:
return False
if self.maximumFileSize is not None and size > self.maximumFileSize:
@@ -52177,6 +52178,11 @@ FILECOUNT_SUMMARY_CHOICE_MAP = {
}
FILECOUNT_SUMMARY_USER = 'Summary'
SIZE_FIELD_CHOICE_MAP = {
'size': 'size',
'quotabytesused': 'quotaBytesUsed'
}
# gam <UserTypeEntity> print filelist [todrive <ToDriveAttribute>*]
# [((query <QueryDriveFile>) | (fullquery <QueryDriveFile>) | <DriveFileQueryShortcut>) (querytime<String> <Time>)*]
# [choose <DriveFileNameEntity>|<DriveFileEntityShortcut>]
@@ -52184,12 +52190,15 @@ FILECOUNT_SUMMARY_USER = 'Summary'
# [select <DriveFileEntity> [selectsubquery <QueryDriveFile>]
# [(norecursion [<Boolean>])|(depth <Number>)] [showparent]]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [showmimetype [not] <MimeTypeList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>] [pmfilter] [oneitemperrow]
# [excludetrashed]
# [maxfiles <Integer>] [nodataheaders <String>]
# [countsonly [summary none|only|plus] [summaryuser <String>] [showsource] [showsize]] [countsrowfilter]
# [countsonly [summary none|only|plus] [summaryuser <String>]
# [showsource] [showsize] [showmimetypesize]]
# [countsrowfilter]
# [filepath|fullpath [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
# [allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
# [showdrivename] [showshareddrivepermissions]
@@ -52213,11 +52222,11 @@ def printFileList(users):
skipObjects.discard('mimeType')
if 'mimeType' not in DFF.fieldsList:
DFF.fieldsList.append('mimeType')
skipObjects.discard('size')
if showSize and 'size' not in DFF.fieldsList:
DFF.fieldsList.append('size')
skipObjects.discard(sizeField)
if showSize and sizeField not in DFF.fieldsList:
DFF.fieldsList.append(sizeField)
if (DLP.minimumFileSize is not None) or (DLP.maximumFileSize is not None):
_setSkipObjects(skipObjects, ['size'], DFF.fieldsList)
_setSkipObjects(skipObjects, [sizeField], DFF.fieldsList)
if DLP.filenameMatchPattern or showParent:
_setSkipObjects(skipObjects, ['name'], DFF.fieldsList)
if DLP.excludeTrashed:
@@ -52244,7 +52253,7 @@ def printFileList(users):
not DLP.CheckShowSharedByMe(f_file) or
not DLP.CheckExcludeTrashed(f_file) or
not DLP.CheckMimeType(f_file) or
not DLP.CheckFileSize(f_file) or
not DLP.CheckFileSize(f_file, sizeField) or
not DLP.CheckFilenameMatch(f_file) or
(not checkSharedDrivePermissions and not DLP.CheckFilePermissionMatches(f_file)) or
(DLP.onlySharedDrives and not driveId)):
@@ -52330,7 +52339,7 @@ def printFileList(users):
else:
mimeTypeInfo.setdefault(fileInfo['mimeType'], {'count': 0, 'size': 0})
mimeTypeInfo[fileInfo['mimeType']['count']] += 1
mimeTypeInfo[fileInfo['mimeType']['size']] += int(fileInfo.get('size', '0'))
mimeTypeInfo[fileInfo['mimeType']['size']] += int(fileInfo.get(sizeField, '0'))
def _printChildDriveFolderContents(drive, fileEntry, user, i, count, depth):
parentFileEntry = fileTree.get(fileEntry['id'])
@@ -52411,6 +52420,7 @@ def printFileList(users):
addPathsToJSON = countsRowFilter = buildTree = countsOnly = filepath = fullpath = getPermissionsForSharedDrives = \
noRecursion = oneItemPerRow = stripCRsFromName = \
showParentsIdsAsList = showDepth = showParent = showSize = showMimeTypeSize = showSource = False
sizeField = 'quotaBytesUsed'
pathDelimiter = '/'
pmselect = True
showLabels = None
@@ -52494,6 +52504,8 @@ def printFileList(users):
csvPFco.SetSortAllTitles()
if myarg == 'showmimetypesize':
showMimeTypeSize = True
elif myarg == 'sizefield':
sizeField = getChoice(SIZE_FIELD_CHOICE_MAP, mapChoice=True)
elif myarg == 'delimiter':
delimiter = getCharacter()
elif myarg == 'showparentsidsaslist':
@@ -52912,7 +52924,8 @@ def printShowFilePaths(users):
# [corpora <CorporaAttribute>]
# [select <SharedDriveEntity>]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [showmimetype [not] <MimeTypeList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
# [excludetrashed]
@@ -52922,7 +52935,8 @@ def printShowFilePaths(users):
# [corpora <CorporaAttribute>]
# [select <SharedDriveEntity>]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [showmimetype [not] <MimeTypeList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
# [excludetrashed]
@@ -52932,7 +52946,7 @@ def printShowFileCounts(users):
if DLP.showOwnedBy is not None:
fieldsList.extend(OWNED_BY_ME_FIELDS_TITLES)
if showSize or (DLP.minimumFileSize is not None) or (DLP.maximumFileSize is not None):
fieldsList.append('size')
fieldsList.append(sizeField)
if DLP.filenameMatchPattern:
fieldsList.append('name')
if DLP.excludeTrashed:
@@ -52975,7 +52989,7 @@ def printShowFileCounts(users):
Ind.Decrement()
else:
if sharedDriveId:
row = {'User': user, 'id': sharedDriveId, 'name': sharedDriveName, 'Total': sizeTotal, 'Item cap': f"{sizeTotal/SHARED_DRIVE_MAX_FILES_FOLDERS:.2%}"}
row = {'User': user, 'id': sharedDriveId, 'name': sharedDriveName, 'Total': countTotal, 'Item cap': f"{sizeTotal/SHARED_DRIVE_MAX_FILES_FOLDERS:.2%}"}
else:
row = {'User': user, 'Total': countTotal}
if showSize:
@@ -52993,6 +53007,7 @@ def printShowFileCounts(users):
DLP = DriveListParameters({'allowChoose': False, 'allowCorpora': True, 'allowQuery': True, 'mimeTypeInQuery': True})
sharedDriveId = sharedDriveName = ''
showSize = showMimeTypeSize = False
sizeField = 'quotaBytesUsed'
summary = FILECOUNT_SUMMARY_NONE
summaryUser = FILECOUNT_SUMMARY_USER
summaryMimeTypeInfo = {}
@@ -53009,6 +53024,8 @@ def printShowFileCounts(users):
fileIdEntity = getSharedDriveEntity()
elif myarg == 'showsize':
showSize = True
elif myarg == 'sizefield':
sizeField = getChoice(SIZE_FIELD_CHOICE_MAP, mapChoice=True)
elif myarg == 'showmimetypesize':
showMimeTypeSize = showSize = True
elif myarg == 'summary':
@@ -53067,7 +53084,7 @@ def printShowFileCounts(users):
if (not DLP.CheckShowOwnedBy(f_file) or
not DLP.CheckShowSharedByMe(f_file) or
not DLP.CheckExcludeTrashed(f_file) or
not DLP.CheckFileSize(f_file) or
not DLP.CheckFileSize(f_file, sizeField) or
not DLP.CheckFilenameMatch(f_file) or
(not checkSharedDrivePermissions and not DLP.CheckFilePermissionMatches(f_file)) or
(DLP.onlySharedDrives and not driveId)):
@@ -53087,10 +53104,9 @@ def printShowFileCounts(users):
GAPI.unknownError, GAPI.invalid, GAPI.badRequest,
GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
continue
fileSize = int(f_file.get('size', '0'))
mimeTypeInfo.setdefault(f_file['mimeType'], {'count': 0, 'size': 0})
mimeTypeInfo[f_file['mimeType']]['count'] += 1
mimeTypeInfo[f_file['mimeType']]['size'] += fileSize
mimeTypeInfo[f_file['mimeType']]['size'] += int(f_file.get(sizeField, '0'))
showMimeTypeInfo(user, mimeTypeInfo, sharedDriveId, sharedDriveName, i, count)
except (GAPI.invalidQuery, GAPI.invalid, GAPI.badRequest):
entityActionFailedWarning([Ent.USER, user, Ent.DRIVE_FILE_OR_FOLDER, None], invalidQuery(DLP.fileIdEntity['query']), i, count)
@@ -53112,6 +53128,7 @@ DISKUSAGE_SHOW_CHOICES = {'all', 'summary', 'summaryandtrash'}
# gam <UserTypeEntity> print diskusage <DriveFileEntity> [todrive <ToDriveAttribute>*]
# [anyowner|(showownedby any|me|others)]
# [sizefield quotabytesused|size]
# [pathdelimiter <Character>] [excludetrashed] [stripcrsfromname]
# (addcsvdata <FieldName> <String>)*
# [noprogress] [show all|summary|summaryandtrash]
@@ -53162,7 +53179,7 @@ def printDiskUsage(users):
elif mimeType != MIMETYPE_GA_SHORTCUT:
if includeOwner and showOwnedBy is not None and childEntryInfo['ownedByMe'] != showOwnedBy:
continue
fsize = int(childEntryInfo.get('size', '0'))
fsize = int(childEntryInfo.get(sizeField, '0'))
fileEntry['directFileCount'] += 1
fileEntry['directFileSize'] += fsize
fileEntry['totalFileCount'] += 1
@@ -53183,6 +53200,7 @@ def printDiskUsage(users):
orderBy = 'folder,name'
zeroFolderInfo = {'directFileCount': 0, 'directFileSize': 0, 'directFolderCount': 0,
'totalFileCount': 0, 'totalFileSize': 0, 'totalFolderCount': 0}
sizeField = 'quotaBytesUsed'
showOwnedBy = showProgress = True
pathDelimiter = '/'
fileIdEntity = getDriveFileEntity()
@@ -53196,6 +53214,8 @@ def printDiskUsage(users):
showOwnedBy = None
elif myarg == 'showownedby':
showOwnedBy = getChoice(SHOW_OWNED_BY_CHOICE_MAP, mapChoice=True)
elif myarg == 'sizefield':
sizeField = getChoice(SIZE_FIELD_CHOICE_MAP, mapChoice=True)
elif myarg == 'pathdelimiter':
pathDelimiter = getCharacter()
elif myarg == 'excludetrashed':
@@ -53213,7 +53233,7 @@ def printDiskUsage(users):
unknownArgumentExit()
if addCSVData:
csvPF.AddTitles(sorted(addCSVData.keys()))
fieldsList = ['id', 'name', 'mimeType', 'size', 'trashed', 'explicitlyTrashed', 'owners(emailAddress)', 'ownedByMe']
fieldsList = ['id', 'name', 'mimeType', sizeField, 'trashed', 'explicitlyTrashed', 'owners(emailAddress)', 'ownedByMe']
pagesFields = getItemFieldsFromFieldsList('files', fieldsList)
topFieldsList = fieldsList[:]
topFieldsList.extend(['driveId', 'parents'])
@@ -53450,7 +53470,8 @@ FILETREE_FIELDS_PRINT_ORDER = ['id', 'parents', 'owners', 'mimeType', 'size', 'e
# gam <UserTypeEntity> print filetree [todrive <ToDriveAttribute>*]
# [select <DriveFileEntity> [selectsubquery <QueryDriveFile>] [depth <Number>]]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [showmimetype [not] <MimeTypeList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
# [excludetrashed]
@@ -53460,7 +53481,8 @@ FILETREE_FIELDS_PRINT_ORDER = ['id', 'parents', 'owners', 'mimeType', 'size', 'e
# gam <UserTypeEntity> show filetree
# [select <DriveFileEntity> [selectsubquery <QueryDriveFile>] [depth <Number>]]
# [anyowner|(showownedby any|me|others)]
# [showmimetype [not] <MimeTypeList>] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [showmimetype [not] <MimeTypeList>]
# [sizefield quotabytesused|size] [minimumfilesize <Integer>] [maximumfilesize <Integer>]
# [filenamematchpattern <RegularExpression>]
# <PermissionMatch>* [<PermissionMatchMode>] [<PermissionMatchAction>]
# [excludetrashed]
@@ -53488,6 +53510,8 @@ def printShowFileTree(users):
trashed = fileEntry.get(field, False)
if trashed:
fileInfoList.extend([field, trashed])
elif field == 'size':
fileInfoList.extend([field, fileEntry.get(sizeField, 0)])
else:
fileInfoList.extend([field, fileEntry.get(field, '')])
if fileInfoList:
@@ -53506,7 +53530,7 @@ def printShowFileTree(users):
elif field == 'owners':
row[field] = delimiter.join([owner['emailAddress'] for owner in fileEntry.get(field, [])])
elif field == 'size':
row[fileSize] = fileEntry.get(field, '')
row[fileSize] = fileEntry.get(sizeField, 0)
else:
row[field] = fileEntry.get(field, '')
csvPF.WriteRow(row)
@@ -53518,7 +53542,7 @@ def printShowFileTree(users):
if not DLP.CheckExcludeTrashed(childEntry['info']):
continue
if (DLP.CheckMimeType(childEntry['info']) and
DLP.CheckFileSize(childEntry['info']) and
DLP.CheckFileSize(childEntry['info'], sizeField) and
DLP.CheckFilenameMatch(childEntry['info']) and
DLP.CheckFilePermissionMatches(childEntry['info'])):
_showFileInfo(childEntry['info'], depth)
@@ -53550,7 +53574,7 @@ def printShowFileTree(users):
continue
if (DLP.CheckShowOwnedBy(childEntryInfo) and
DLP.CheckMimeType(childEntryInfo) and
DLP.CheckFileSize(childEntryInfo) and
DLP.CheckFileSize(childEntryInfo, sizeField) and
DLP.CheckFilenameMatch(childEntryInfo) and
DLP.CheckFilePermissionMatches(childEntryInfo)):
_showFileInfo(childEntryInfo, depth)
@@ -53563,8 +53587,7 @@ def printShowFileTree(users):
maxdepth = -1
fileIdEntity = {}
selectSubQuery = ''
fieldsList = ['driveId', 'id', 'name', 'parents', 'mimeType', 'ownedByMe', 'owners(emailAddress)',
'shared', 'size', 'explicitlyTrashed', 'trashed']
sizeField = 'quotaBytesUsed'
showFields = {}
for mappedField in FILETREE_FIELDS_CHOICE_MAP.values():
showFields[mappedField] = False
@@ -53588,6 +53611,8 @@ def printShowFileTree(users):
OBY.GetChoice()
elif myarg == 'depth':
maxdepth = getInteger(minVal=-1)
elif myarg == 'sizefield':
sizeField = getChoice(SIZE_FIELD_CHOICE_MAP, mapChoice=True)
elif myarg == 'fields':
for field in _getFieldsList():
if field in FILETREE_FIELDS_CHOICE_MAP:
@@ -53604,6 +53629,8 @@ def printShowFileTree(users):
stripCRsFromName = True
else:
unknownArgumentExit()
fieldsList = ['driveId', 'id', 'name', 'parents', 'mimeType', 'ownedByMe', 'owners(emailAddress)',
'shared', sizeField, 'explicitlyTrashed', 'trashed']
if csvPF:
if not GC.Values[GC.DRIVE_V3_NATIVE_NAMES]:
fileNameTitle = 'title'
@@ -54900,7 +54927,6 @@ def _copyPermissions(drive, user, i, count, j, jcount,
def isPermissionCopyable(kvList, permission):
role = permission['role']
if permission['type'] in {'group', 'user'}:
emailAddress = permission.get('emailAddress', '')
domain = ''
if copyMoveOptions['excludePermissionsFromDomains'] or copyMoveOptions['includePermissionsFromDomains']:
@@ -56913,7 +56939,7 @@ def getDriveFile(users):
try:
result = callGAPI(drive.files(), 'get',
throwReasons=GAPI.DRIVE_GET_THROW_REASONS,
fileId=fileId, fields='name,fullFileExtension,mimeType,size,shortcutDetails', supportsAllDrives=True)
fileId=fileId, fields='name,fullFileExtension,mimeType,quotaBytesUsed,shortcutDetails', supportsAllDrives=True)
mimeType = result['mimeType']
if (mimeType == MIMETYPE_GA_SHORTCUT) and not donotFollowShortcuts:
fileId = result['shortcutDetails']['targetId']
@@ -56946,8 +56972,8 @@ def getDriveFile(users):
entityActionNotPerformedWarning(entityValueList, Msg.FORMAT_NOT_AVAILABLE.format(','.join(exportFormatChoices)), j, jcount)
continue
else:
if 'size' in result:
my_line = ['Size', formatFileSize(int(result['size']))]
if 'quotaBytesUsed' in result:
my_line = ['Size', formatFileSize(int(result['quotaBytesUsed']))]
else:
my_line = ['Size', UNKNOWN]
googleDoc = False