mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-28 09:51:36 +00:00
Added command gam <UserTypeEntity> print diskusage to display disk usage by folder.
This commit is contained in:
@@ -10,6 +10,16 @@ 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.62.05
|
||||
|
||||
Added progress messages (suppressible) to `gam <UserTypeEntity> print diskusage`.
|
||||
|
||||
### 6.62.04
|
||||
|
||||
Added command `gam <UserTypeEntity> print diskusage` to display disk usage by folder.
|
||||
|
||||
* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Files-Display#display-disk-usage
|
||||
|
||||
### 6.62.03
|
||||
|
||||
Handled Google Directory API bug in `gam print groups` that caused a trap.
|
||||
|
||||
@@ -329,7 +329,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.62.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
GAMADV-XTD3 6.62.05 - 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
|
||||
@@ -969,7 +969,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.62.00 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
GAMADV-XTD3 6.62.05 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource
|
||||
Ross Scroggs <ross.scroggs@gmail.com>
|
||||
Python 3.11.4 64-bit final
|
||||
Windows-10-10.0.17134 AMD64
|
||||
@@ -1234,6 +1234,8 @@ Section: DEFAULT
|
||||
num_threads = 5
|
||||
oauth2_txt = oauth2.txt ; C:\GAMConfig\oauth2.txt
|
||||
oauth2service_json = oauth2service.json ; C:\GAMConfig\oauth2service.json
|
||||
output_dateformat = ''
|
||||
output_timeformat = ''
|
||||
people_max_results = 100
|
||||
quick_cros_move = false
|
||||
quick_info_user = False
|
||||
|
||||
@@ -53,6 +53,7 @@ use the `returnnameonly` option to have GAM display just the profile name of the
|
||||
This will be useful in scripts that create|update a profile and then want to perform subsequent GAM commands that
|
||||
reference the profile.
|
||||
|
||||
```
|
||||
gam delete inboundssoprofile <SSOProfileItem>
|
||||
```
|
||||
|
||||
|
||||
@@ -11,3 +11,5 @@ Thank you.
|
||||
* Amado Tejada - https://github.com/amadotejada/GAMpass
|
||||
* Workspace Admins YouTube Channel - https://youtube.com/@googleworkspaceadmins
|
||||
* Goldy Arora - https://www.goldyarora.com/license-notifier/
|
||||
* Paul Ogier (Taming.Tech) - GAMADV-XTD3 Tutorials https://www.youtube.com/watch?v=g9LDeyXQNLI&list=PL_dLiK09pJVhKJxZHNk9CHK0q5hkZ856w
|
||||
* Paul Ogier (Taming.Tech) - GAMADV-XTD3 Course on Udemy https://taming.tech/GAMCourse
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
- [File selection starting point for Display file list](#file-selection-starting-point-for-display-file-list)
|
||||
- [File selection with a particular drive label](#file-selection-with-a-particular-drive-label)
|
||||
- [Handle empty file lists](#handle-empty-file-lists)
|
||||
- [Display disk usage](#display-disk-usage)
|
||||
|
||||
## API documentation
|
||||
* https://developers.google.com/drive/api/v3/reference/files
|
||||
@@ -1350,3 +1351,93 @@ Got 0 Drive Files/Folders that matched query ('me' in owners and name contains '
|
||||
$ more Files.csv
|
||||
BadNews-NoData
|
||||
```
|
||||
## Display disk usage
|
||||
```
|
||||
gam <UserTypeEntity> print diskusage <DriveFileEntity> [todrive <ToDriveAttribute>*]
|
||||
[anyowner|(showownedby any|me|others)]
|
||||
[pathdelimiter <Character>] [excludetrashed] [stripcrsfromname]
|
||||
(addcsvdata <FieldName> <String>)*
|
||||
[noprogress] [show all|summary|summaryandtrash]
|
||||
```
|
||||
For each folder in `<DiskFileEntity>`, the following items are displayed:
|
||||
* `User` - The email address of the user in `<UserTypeEntity>`
|
||||
* `Owner` - The email address of the owner of the folder; omitted when displaying disk usage on Shared Drives
|
||||
* `ownedByMe` - True if the folder is owned by `User`, False otherwise; omitted when displaying disk usage on Shared Drives
|
||||
* `id` - The folder ID
|
||||
* `name` - The Folder name
|
||||
* `trashed` - True if the folder has been trashed, either explicitly or from a trashed parent folder, False otherwise
|
||||
* `explicitlyTrashed` - True if the folder has been explicitly trashed, as opposed to recursively trashed from a parent folder, False otherwise
|
||||
* `directFileCount` - The number of files directly in the folder
|
||||
* `directFileSize` - The sum of the sizes of the files directly in the folder
|
||||
* `directFolderCount` - The number of folders directly in the folder
|
||||
* `totalFileCount` - The number of files directly in the folder and all of its subfolders
|
||||
* `totalFileSize` - The sum of the sizes of the files directly in the folder and all of its subfolders
|
||||
* `totalFolderCount` - The number of folders directly in the folder and all of its subfolders
|
||||
* `path` - The path of the folder
|
||||
|
||||
There is a final row detailing files and folders in the trash; it is omitted if `excludetrashed` or `show summary` are specified.
|
||||
* `User` - The email address of the user in `<UserTypeEntity>`
|
||||
* `Owner` - The email address of the user in `<UserTypeEntity>`
|
||||
* `ownedByMe` - True
|
||||
* `id` - Trash
|
||||
* `name` - Trash
|
||||
* `trashed` - True if there are any items in the trash
|
||||
* `explicitlyTrashed` - True if any items have been explicitly trashed
|
||||
* `directFileCount` - The number of explicitly trashed files
|
||||
* `directFileSize` - The sum of the sizes of the explicitly trashed files
|
||||
* `directFolderCount` - The number of explicitly trashed folders
|
||||
* `totalFileCount` - The number of files in the trash
|
||||
* `totalFileSize` - The sum of the sizes of the files in the trash
|
||||
* `totalFolderCount` - The number of folders in the trash
|
||||
* `path` - Trash
|
||||
|
||||
By default, files owned by the user are counted. These options update the current query with the desired ownership.
|
||||
* `showownedby me` - Count files owned by the user; this is the default
|
||||
* `showownedby any` or `anyowner` - Count files accessible by the user
|
||||
* `showownedby others` - Count files not owned by the user
|
||||
|
||||
All folders are counted, regardless of ownership.
|
||||
|
||||
By default, file path components are separated by `/`; use `pathdelimiter <Character>` to use `<Character>` as the separator.
|
||||
|
||||
Use the `excludetrashed` option to suppress counting files and folders in the trash.
|
||||
|
||||
The `stripcrsfromname` option strips nulls, carriage returns and linefeeds from drive file names.
|
||||
Use this option if you discover filenames containing these special characters; it is not common.
|
||||
|
||||
Add additional columns of data from the command line to the output:
|
||||
* `addcsvdata <FieldName> <String>`
|
||||
|
||||
By default, progress messages are displayed for each folder, use `noprogress` to suppress these messages.
|
||||
|
||||
Use the `show` option to control the display of data:
|
||||
* `all` - Display a row for every folder in `<DriveFileEntity>` and a row detailing items in the trash when `excludetrashed` is omitted. This is the default.
|
||||
* `summary` - Display a single row for the first folder in `<DriveFileEntity>`
|
||||
* `summaryandtrash` - Display a single row for the first folder in `<DriveFileEntity>` and a row detailing items in the trash when `excludetrashed` is omitted.
|
||||
|
||||
### Examples
|
||||
```
|
||||
$ gam redirect csv ./MyDriveUsage.csv user testsimple@domain.com print diskusage mydrive
|
||||
User: testsimple@domain.com, Print 1 Drive Disk Usage
|
||||
$ more MyDriveUsage.csv
|
||||
User,Owner,id,name,ownedByMe,trashed,explicitlyTrashed,directFileCount,directFileSize,directFolderCount,totalFileCount,totalFileSize,totalFolderCount,path
|
||||
testsimple@domain.com,testsimple@domain.com,012YenC8f12ALUk9PVA,My Drive,,False,False,100,138212,24,167,189598,79,My Drive
|
||||
testsimple@domain.com,testsimple@domain.com,456YenC8f12ALfndaQ1NHc0RtUG92Y1BIUUl4bjVBRmNkWG5oakNqVVFDcXJWOHNmdFlwZmc,Classroom,True,False,False,0,0,15,9,6840,17,My Drive/Classroom
|
||||
...
|
||||
testsimple@domain.com,testsimple@domain.com,1bHS_Tp77W3KSGRNSs_jP1RhAJhIGRCaI,XferFolder,True,False,False,1,1024,0,1,1024,0,My Drive/XferFolder
|
||||
testsimple@domain.com,testsimple@domain.com,Trash,Trash,,True,True,0,0,1,3,3072,9,Trash
|
||||
|
||||
$ gam redirect csv ./MyDriveUsage.csv user testsimple@domain.com print diskusage mydrive show summaryandtrash
|
||||
User: testsimple@domain.com, Print 1 Drive Disk Usage
|
||||
$ more MyDriveUsage.csv
|
||||
User,Owner,id,name,ownedByMe,trashed,explicitlyTrashed,directFileCount,directFileSize,directFolderCount,totalFileCount,totalFileSize,totalFolderCount,path
|
||||
testsimple@domain.com,testsimple@domain.com,012YenC8f12ALUk9PVA,My Drive,,False,False,100,138212,24,167,189598,79,My Drive
|
||||
testsimple@domain.com,testsimple@domain.com,Trash,Trash,,True,True,0,0,1,3,3072,9,Trash
|
||||
|
||||
$ gam redirect csv ./MyDriveUsage.csv user testsimple@domain.com print diskusage shareddriveid 0AL5LiIe4dqxZUk9PVA show summaryandtrash
|
||||
User: testsimple@domain.com, Print 1 Drive Disk Usage
|
||||
$ more MyDriveUsage.csv
|
||||
User,id,name,trashed,explicitlyTrashed,directFileCount,directFileSize,directFolderCount,totalFileCount,totalFileSize,totalFolderCount,path
|
||||
testsimple@domain.com,0125LiIe4dqxZUk9PVA,TS Shared Drive 1,False,False,16,6144,7,42,73799,25,SharedDrives/TS Shared Drive 1
|
||||
testsimple@domain.com,Trash,Trash,True,True,1,1024,0,1,1024,0,Trash
|
||||
```
|
||||
|
||||
@@ -69,7 +69,7 @@ Alternatively, you can direct the output to a CSV file:
|
||||
To retrieve the shortcut ID with `returnidonly`:
|
||||
```
|
||||
Linux/MacOS
|
||||
fileId=`gam user user@domain.com create drivefileshortcut ... returnidonly`
|
||||
fileId=$(gam user user@domain.com create drivefileshortcut ... returnidonly)
|
||||
Windows PowerShell
|
||||
$fileId = & gam user user@domain.com create drivefileshortcut ... returnidonly
|
||||
```
|
||||
|
||||
@@ -6556,6 +6556,12 @@ gam <UserTypeEntity> print filelist [todrive <ToDriveAttribute>*]
|
||||
(addcsvdata <FieldName> <String>)*
|
||||
[formatjson [quotechar <Character>]]
|
||||
|
||||
gam <UserTypeEntity> print diskusage <DriveFileEntity> [todrive <ToDriveAttribute>*]
|
||||
[anyowner|(showownedby any|me|others)]
|
||||
[pathdelimiter <Character>] [excludetrashed] [stripcrsfromname]
|
||||
(addcsvdata <FieldName> <String>)*
|
||||
[noprogress] [show all|summary|summaryandtrash]
|
||||
|
||||
<DriveActivityAction> ::=
|
||||
comment|
|
||||
create|
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
Merged GAM-Team version
|
||||
|
||||
6.62.05
|
||||
|
||||
Added progress messages (suppressible) to `gam <UserTypeEntity> print diskusage`.
|
||||
|
||||
6.62.04
|
||||
|
||||
Added command `gam <UserTypeEntity> print diskusage` to display disk usage by folder.
|
||||
|
||||
* See: https://github.com/taers232c/GAMADV-XTD3/wiki/Users-Drive-Files-Display#display-disk-usage
|
||||
|
||||
6.62.03
|
||||
|
||||
Handled Google Directory API bug in `gam print groups` that caused a trap.
|
||||
|
||||
@@ -51209,6 +51209,8 @@ def noFileSelectFileIdEntity(fileIdEntity):
|
||||
and not fileIdEntity['shareddrivefilequery']
|
||||
and not fileIdEntity['list']))
|
||||
|
||||
SHOW_OWNED_BY_CHOICE_MAP = {'any': None, 'me': True, 'others': False}
|
||||
|
||||
class DriveListParameters():
|
||||
def __init__(self, myargOptions):
|
||||
self.PM = PermissionMatch()
|
||||
@@ -51230,7 +51232,6 @@ class DriveListParameters():
|
||||
self.showOwnedBy = True
|
||||
self.showSharedByMe = None
|
||||
|
||||
SHOW_OWNED_BY_CHOICE_MAP = {'any': None, 'me': True, 'others': False}
|
||||
SHOW_SHARED_BY_ME_CHOICE_MAP = {'any': None, 'true': True, 'false': False}
|
||||
|
||||
def ProcessArgument(self, myarg, fileIdEntity):
|
||||
@@ -51250,7 +51251,7 @@ class DriveListParameters():
|
||||
self.showOwnedBy = None
|
||||
self.UpdateAnyOwnerQuery()
|
||||
elif myarg == 'showownedby':
|
||||
self.showOwnedBy = getChoice(self.SHOW_OWNED_BY_CHOICE_MAP, mapChoice=True)
|
||||
self.showOwnedBy = getChoice(SHOW_OWNED_BY_CHOICE_MAP, mapChoice=True)
|
||||
self.UpdateQueryWithShowOwnedBy()
|
||||
elif myarg == 'showmimetype':
|
||||
self.mimeTypeCheck.Get()
|
||||
@@ -52437,6 +52438,200 @@ def printShowFileCounts(users):
|
||||
if csvPF:
|
||||
csvPF.writeCSVfile('Drive File Counts')
|
||||
|
||||
DISKUSAGE_SHOW_CHOICES = {'all', 'summary', 'summaryandtrash'}
|
||||
|
||||
# gam <UserTypeEntity> print diskusage <DriveFileEntity> [todrive <ToDriveAttribute>*]
|
||||
# [anyowner|(showownedby any|me|others)]
|
||||
# [pathdelimiter <Character>] [excludetrashed] [stripcrsfromname]
|
||||
# (addcsvdata <FieldName> <String>)*
|
||||
# [noprogress] [show all|summary|summaryandtrash]
|
||||
def printDiskUsage(users):
|
||||
def _getChildDriveFolderInfo(drive, fileEntry, user, i, count):
|
||||
q = WITH_PARENTS.format(fileEntry['id'])
|
||||
try:
|
||||
children = callGAPIpages(drive.files(), 'list', 'files',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID],
|
||||
retryReasons=[GAPI.UNKNOWN_ERROR],
|
||||
q=q, orderBy=orderBy, fields=pagesFields,
|
||||
pageSize=GC.Values[GC.DRIVE_MAX_RESULTS], supportsAllDrives=True, includeItemsFromAllDrives=True)
|
||||
except (GAPI.invalidQuery, GAPI.invalid):
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.DRIVE_FOLDER, None], invalidQuery(q), i, count)
|
||||
return
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
userSvcNotApplicableOrDriveDisabled(user, str(e), i, count)
|
||||
return
|
||||
Ind.Increment()
|
||||
if showProgress:
|
||||
entityActionPerformed([Ent.USER, user, Ent.DRIVE_FOLDER, fileEntry['path']])
|
||||
for childEntryInfo in children:
|
||||
trashed = childEntryInfo['trashed']
|
||||
if trashed and excludeTrashed:
|
||||
continue
|
||||
mimeType = childEntryInfo.pop('mimeType')
|
||||
if mimeType == MIMETYPE_GA_FOLDER:
|
||||
fileEntry['directFolderCount'] += 1
|
||||
fileEntry['totalFolderCount'] += 1
|
||||
if trashed:
|
||||
trashFolder['totalFolderCount'] += 1
|
||||
if childEntryInfo['explicitlyTrashed']:
|
||||
trashFolder['directFolderCount'] += 1
|
||||
childEntryInfo['User'] = user
|
||||
if includeOwner:
|
||||
owners = childEntryInfo.pop('owners', [])
|
||||
if owners:
|
||||
childEntryInfo['Owner'] = owners[0].get('emailAddress', 'Unknown')
|
||||
childEntryInfo.update(zeroFolderInfo)
|
||||
if stripCRsFromName:
|
||||
childEntryInfo['name'] = _stripControlCharsFromName(childEntryInfo['name'])
|
||||
childEntryInfo['path'] = fileEntry['path']+pathDelimiter+childEntryInfo['name']
|
||||
foldersList.append(childEntryInfo)
|
||||
_getChildDriveFolderInfo(drive, childEntryInfo, user, i, count)
|
||||
fileEntry['totalFileCount'] += childEntryInfo['totalFileCount']
|
||||
fileEntry['totalFileSize'] += childEntryInfo['totalFileSize']
|
||||
fileEntry['totalFolderCount'] += childEntryInfo['totalFolderCount']
|
||||
elif mimeType != MIMETYPE_GA_SHORTCUT:
|
||||
if includeOwner and showOwnedBy is not None and childEntryInfo['ownedByMe'] != showOwnedBy:
|
||||
continue
|
||||
fsize = int(childEntryInfo.get('size', '0'))
|
||||
fileEntry['directFileCount'] += 1
|
||||
fileEntry['directFileSize'] += fsize
|
||||
fileEntry['totalFileCount'] += 1
|
||||
fileEntry['totalFileSize'] += fsize
|
||||
if trashed:
|
||||
trashFolder['totalFileCount'] += 1
|
||||
trashFolder['totalFileSize'] += fsize
|
||||
if childEntryInfo['explicitlyTrashed']:
|
||||
trashFolder['directFileCount'] += 1
|
||||
trashFolder['directFileSize'] += fsize
|
||||
Ind.Decrement()
|
||||
|
||||
csvPF = CSVPrintFile(['User', 'Owner', 'id', 'name', 'ownedByMe', 'trashed', 'explicitlyTrashed',
|
||||
'directFileCount', 'directFileSize', 'directFolderCount',
|
||||
'totalFileCount', 'totalFileSize', 'totalFolderCount', 'path'])
|
||||
excludeTrashed = stripCRsFromName = False
|
||||
includeOwner = True
|
||||
orderBy = 'folder,name'
|
||||
zeroFolderInfo = {'directFileCount': 0, 'directFileSize': 0, 'directFolderCount': 0,
|
||||
'totalFileCount': 0, 'totalFileSize': 0, 'totalFolderCount': 0}
|
||||
showOwnedBy = showProgress = True
|
||||
pathDelimiter = '/'
|
||||
fileIdEntity = getDriveFileEntity()
|
||||
addCSVData = {}
|
||||
showResults = 'all'
|
||||
while Cmd.ArgumentsRemaining():
|
||||
myarg = getArgument()
|
||||
if myarg == 'todrive':
|
||||
csvPF.GetTodriveParameters()
|
||||
elif myarg == 'anyowner':
|
||||
showOwnedBy = None
|
||||
elif myarg == 'showownedby':
|
||||
showOwnedBy = getChoice(SHOW_OWNED_BY_CHOICE_MAP, mapChoice=True)
|
||||
elif myarg == 'pathdelimiter':
|
||||
pathDelimiter = getCharacter()
|
||||
elif myarg == 'excludetrashed':
|
||||
excludeTrashed = True
|
||||
elif myarg == 'stripcrsfromname':
|
||||
stripCRsFromName = True
|
||||
elif myarg == 'addcsvdata':
|
||||
k = getString(Cmd.OB_STRING)
|
||||
addCSVData[k] = getString(Cmd.OB_STRING, minLen=0)
|
||||
elif myarg == 'show':
|
||||
showResults = getChoice(DISKUSAGE_SHOW_CHOICES)
|
||||
elif myarg == 'noprogress':
|
||||
showProgress = False
|
||||
else:
|
||||
unknownArgumentExit()
|
||||
if addCSVData:
|
||||
csvPF.AddTitles(sorted(addCSVData.keys()))
|
||||
fieldsList = ['id', 'name', 'mimeType', 'size', 'trashed', 'explicitlyTrashed', 'owners(emailAddress)', 'ownedByMe']
|
||||
pagesFields = getItemFieldsFromFieldsList('files', fieldsList)
|
||||
topFieldsList = fieldsList[:]
|
||||
topFieldsList.extend(['driveId', 'parents'])
|
||||
topFields = getFieldsFromFieldsList(topFieldsList)
|
||||
i, count, users = getEntityArgument(users)
|
||||
i = 0
|
||||
for user in users:
|
||||
i += 1
|
||||
origUser = user
|
||||
user, drive, jcount = _validateUserGetFileIDs(origUser, i, count, fileIdEntity, entityType=Ent.DRIVE_DISK_USAGE)
|
||||
if jcount == 0:
|
||||
continue
|
||||
j = 0
|
||||
for fileId in fileIdEntity['list']:
|
||||
j += 1
|
||||
foldersList = []
|
||||
trashFolder = {'User': user, 'id': 'Trash', 'name': 'Trash', 'path': 'Trash'}
|
||||
trashFolder.update(zeroFolderInfo)
|
||||
try:
|
||||
topFolder = callGAPI(drive.files(), 'get',
|
||||
throwReasons=GAPI.DRIVE_GET_THROW_REASONS,
|
||||
fileId=fileId, fields=topFields, supportsAllDrives=True)
|
||||
if stripCRsFromName:
|
||||
topFolder['name'] = _stripControlCharsFromName(topFolder['name'])
|
||||
mimeType = topFolder.pop('mimeType')
|
||||
if mimeType != MIMETYPE_GA_FOLDER:
|
||||
entityValueList = [Ent.USER, user, _getEntityMimeType(topFolder), topFolder['name']]
|
||||
entityActionNotPerformedWarning(entityValueList, Msg.INVALID_MIMETYPE.format(mimeType, MIMETYPE_GA_FOLDER), i, count)
|
||||
continue
|
||||
if topFolder['trashed']:
|
||||
if excludeTrashed:
|
||||
entityValueList = [Ent.USER, user, Ent.DRIVE_FOLDER, topFolder['name']]
|
||||
entityActionNotPerformedWarning(entityValueList, Msg.IN_TRASH_AND_EXCLUDE_TRASHED, i, count)
|
||||
continue
|
||||
trashFolder['totalFolderCount'] += 1
|
||||
if topFolder['explicitlyTrashed']:
|
||||
trashFolder['directFolderCount'] += 1
|
||||
driveId = topFolder.pop('driveId', None)
|
||||
if driveId:
|
||||
includeOwner = False
|
||||
csvPF.RemoveTitles(['Owner', 'ownedByMe'])
|
||||
if topFolder['name'] == TEAM_DRIVE and not topFolder.get('parents'):
|
||||
topFolder['name'] = _getSharedDriveNameFromId(drive, driveId)
|
||||
topFolder['path'] = f'{SHARED_DRIVES}{pathDelimiter}{topFolder["name"]}'
|
||||
else:
|
||||
topFolder['path'] = topFolder['name']
|
||||
elif topFolder['name'] == MY_DRIVE and not topFolder.get('parents'):
|
||||
topFolder['path'] = MY_DRIVE
|
||||
else:
|
||||
topFolder['path'] = topFolder['name']
|
||||
topFolder['User'] = user
|
||||
if includeOwner:
|
||||
owners = topFolder.pop('owners', [])
|
||||
if owners:
|
||||
topFolder['Owner'] = owners[0].get('emailAddress', 'Unknown')
|
||||
trashFolder['Owner'] = topFolder['Owner']
|
||||
topFolder.pop('ownedByMe', None)
|
||||
topFolder.pop('parents', None)
|
||||
topFolder.update(zeroFolderInfo)
|
||||
foldersList.append(topFolder)
|
||||
_getChildDriveFolderInfo(drive, topFolder, user, i, count)
|
||||
except GAPI.fileNotFound:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.DRIVE_FOLDER, fileId], Msg.NOT_FOUND, j, jcount)
|
||||
continue
|
||||
except (GAPI.notFound, GAPI.teamDriveMembershipRequired) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, fileIdEntity['shareddrive']['driveId']], str(e), j, jcount)
|
||||
continue
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
userSvcNotApplicableOrDriveDisabled(user, str(e), i, count)
|
||||
break
|
||||
if showResults == 'all':
|
||||
for folder in foldersList:
|
||||
if addCSVData:
|
||||
folder.update(addCSVData)
|
||||
csvPF.WriteRow(folder)
|
||||
else:
|
||||
folder = foldersList[0]
|
||||
if addCSVData:
|
||||
folder.update(addCSVData)
|
||||
csvPF.WriteRow(folder)
|
||||
if showResults != 'summary' and not excludeTrashed:
|
||||
trashFolder['trashed'] = trashFolder['totalFileCount']+trashFolder['totalFolderCount'] > 0
|
||||
trashFolder['explicitlyTrashed'] = trashFolder['directFileCount']+trashFolder['directFolderCount'] > 0
|
||||
if addCSVData:
|
||||
trashFolder.update(addCSVData)
|
||||
csvPF.WriteRow(trashFolder)
|
||||
csvPF.writeCSVfile('Drive Disk Usage')
|
||||
|
||||
FILESHARECOUNTS_OWNER = 'Owner'
|
||||
FILESHARECOUNTS_TOTAL = 'Total'
|
||||
FILESHARECOUNTS_SHARED = 'Shared'
|
||||
@@ -70356,6 +70551,7 @@ USER_COMMANDS_WITH_OBJECTS = {
|
||||
Cmd.ARG_DATASTUDIOASSET: printShowDataStudioAssets,
|
||||
Cmd.ARG_DATASTUDIOPERMISSION: printShowDataStudioPermissions,
|
||||
Cmd.ARG_DELEGATE: printShowDelegates,
|
||||
Cmd.ARG_DISKUSAGE: printDiskUsage,
|
||||
Cmd.ARG_DRIVEACTIVITY: printDriveActivity,
|
||||
Cmd.ARG_DRIVEFILEACL: printShowDriveFileACLs,
|
||||
Cmd.ARG_DRIVELABEL: printShowDriveLabels,
|
||||
@@ -70447,6 +70643,7 @@ USER_COMMANDS_WITH_OBJECTS = {
|
||||
Cmd.ARG_DATASTUDIOASSET: printShowDataStudioAssets,
|
||||
Cmd.ARG_DATASTUDIOPERMISSION: printShowDataStudioPermissions,
|
||||
Cmd.ARG_DELEGATE: printShowDelegates,
|
||||
Cmd.ARG_DISKUSAGE: printDiskUsage,
|
||||
Cmd.ARG_DRIVEACTIVITY: printDriveActivity,
|
||||
Cmd.ARG_DRIVEFILEACL: printShowDriveFileACLs,
|
||||
Cmd.ARG_DRIVELABEL: printShowDriveLabels,
|
||||
|
||||
@@ -532,6 +532,7 @@ class GamCLArgs():
|
||||
ARG_DEVICEUSER = 'deviceuser'
|
||||
ARG_DEVICEUSERS = 'deviceusers'
|
||||
ARG_DEVICEUSERSTATE = 'deviceuserstate'
|
||||
ARG_DISKUSAGE = 'diskusage'
|
||||
ARG_DOCUMENT = 'document'
|
||||
ARG_DOMAIN = 'domain'
|
||||
ARG_DOMAINS = 'domains'
|
||||
|
||||
@@ -170,6 +170,7 @@ class GamEntity():
|
||||
DOMAIN_CONTACT = 'doco'
|
||||
DOMAIN_PEOPLE_CONTACT = 'dopc'
|
||||
DOMAIN_PROFILE = 'dopr'
|
||||
DRIVE_DISK_USAGE = 'drdu'
|
||||
DRIVE_FILE = 'dfil'
|
||||
DRIVE_FILE_ID = 'fili'
|
||||
DRIVE_FILE_NAME = 'filn'
|
||||
@@ -495,6 +496,7 @@ class GamEntity():
|
||||
DOMAIN_CONTACT: ['Domain Contacts', 'Domain Contact'],
|
||||
DOMAIN_PEOPLE_CONTACT: ['Domain People Contacts', 'Domain People Contact'],
|
||||
DOMAIN_PROFILE: ['Domain Profiles', 'Domain Profile'],
|
||||
DRIVE_DISK_USAGE: ['Drive Disk Usages', 'Drive Disk Usage'],
|
||||
DRIVE_FILE: ['Drive Files', 'Drive File'],
|
||||
DRIVE_FILE_ID: ['Drive File IDs', 'Drive File ID'],
|
||||
DRIVE_FILE_NAME: ['Drive File Names', 'Drive File Name'],
|
||||
|
||||
Reference in New Issue
Block a user