|
|
|
|
@@ -25,7 +25,7 @@ https://github.com/GAM-team/GAM/wiki
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
__author__ = 'GAM Team <google-apps-manager@googlegroups.com>'
|
|
|
|
|
__version__ = '7.05.15'
|
|
|
|
|
__version__ = '7.05.17'
|
|
|
|
|
__license__ = 'Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
|
|
|
|
|
|
|
|
|
|
#pylint: disable=wrong-import-position
|
|
|
|
|
@@ -4113,8 +4113,8 @@ def SetGlobalVariables():
|
|
|
|
|
if checkArgumentPresent(Cmd.MULTIPROCESSEXIT_CMD):
|
|
|
|
|
_setMultiprocessExit()
|
|
|
|
|
# redirect csv <FileName> [multiprocess] [append] [noheader] [charset <CharSet>]
|
|
|
|
|
# [columndelimiter <Character>] [noescapechar <Boolean>] [quotechar <Character>]]
|
|
|
|
|
# [sortheaders <StringList>] [timestampcolumn <String>]
|
|
|
|
|
# [columndelimiter <Character>] [noescapechar [<Boolean>]] [quotechar <Character>]]
|
|
|
|
|
# [sortheaders <StringList>] [timestampcolumn <String>] [transpose [<Boolean>]]
|
|
|
|
|
# [todrive <ToDriveAttribute>*]
|
|
|
|
|
# redirect stdout <FileName> [multiprocess] [append]
|
|
|
|
|
# redirect stdout null
|
|
|
|
|
@@ -4139,6 +4139,8 @@ def SetGlobalVariables():
|
|
|
|
|
GM.Globals[GM.CSV_OUTPUT_SORT_HEADERS] = GC.Values[GC.CSV_OUTPUT_SORT_HEADERS] = getString(Cmd.OB_STRING_LIST, minLen=0).replace(',', ' ').split()
|
|
|
|
|
if checkArgumentPresent('timestampcolumn'):
|
|
|
|
|
GM.Globals[GM.CSV_OUTPUT_TIMESTAMP_COLUMN] = GC.Values[GC.CSV_OUTPUT_TIMESTAMP_COLUMN] = getString(Cmd.OB_STRING, minLen=0)
|
|
|
|
|
if checkArgumentPresent('transpose'):
|
|
|
|
|
GM.Globals[GM.CSV_OUTPUT_TRANSPOSE] = getBoolean()
|
|
|
|
|
_setCSVFile(filename, mode, encoding, writeHeader, multi)
|
|
|
|
|
GM.Globals[GM.CSVFILE][GM.REDIRECT_QUEUE_CSVPF] = CSVPrintFile()
|
|
|
|
|
if checkArgumentPresent('todrive'):
|
|
|
|
|
@@ -7794,6 +7796,7 @@ class CSVPrintFile():
|
|
|
|
|
def __init__(self, titles=None, sortTitles=None, indexedTitles=None):
|
|
|
|
|
self.rows = []
|
|
|
|
|
self.rowCount = 0
|
|
|
|
|
self.outputTranspose = GM.Globals[GM.CSV_OUTPUT_TRANSPOSE]
|
|
|
|
|
self.todrive = GM.Globals[GM.CSV_TODRIVE]
|
|
|
|
|
self.titlesSet = set()
|
|
|
|
|
self.titlesList = []
|
|
|
|
|
@@ -8993,6 +8996,22 @@ class CSVPrintFile():
|
|
|
|
|
self.JSONtitlesList = self.orderHeaders(self.JSONtitlesList)
|
|
|
|
|
titlesList = self.JSONtitlesList
|
|
|
|
|
normalizeSortHeaders()
|
|
|
|
|
if self.outputTranspose:
|
|
|
|
|
newRows = []
|
|
|
|
|
pivotKey = titlesList[0]
|
|
|
|
|
newTitlesList = [pivotKey]
|
|
|
|
|
newTitlesSet = set(newTitlesList)
|
|
|
|
|
for title in titlesList[1:]:
|
|
|
|
|
newRow = {pivotKey: title}
|
|
|
|
|
for row in self.rows:
|
|
|
|
|
pivotValue = row[pivotKey]
|
|
|
|
|
if pivotValue not in newTitlesSet:
|
|
|
|
|
newTitlesSet.add(pivotValue)
|
|
|
|
|
newTitlesList.append(pivotValue)
|
|
|
|
|
newRow[pivotValue] = row.get(title)
|
|
|
|
|
newRows.append(newRow)
|
|
|
|
|
titlesList = newTitlesList
|
|
|
|
|
self.rows = newRows
|
|
|
|
|
if (not self.todrive) or self.todrive['localcopy']:
|
|
|
|
|
if GM.Globals[GM.CSVFILE][GM.REDIRECT_NAME] == '-':
|
|
|
|
|
if GM.Globals[GM.STDOUT][GM.REDIRECT_MULTI_FD]:
|
|
|
|
|
@@ -58726,7 +58745,7 @@ def _copyPermissions(drive, user, i, count, j, jcount,
|
|
|
|
|
except (GAPI.notFound, GAPI.permissionNotFound,
|
|
|
|
|
GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
|
|
|
|
GAPI.fileNeverWritable, GAPI.badRequest, GAPI.cannotRemoveOwner, GAPI.cannotModifyInheritedTeamDrivePermission,
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded) as e:
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded, GAPI.cannotDeletePermission) as e:
|
|
|
|
|
entityActionFailedWarning(kvList, str(e), k, kcount)
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
|
|
|
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
|
|
|
|
@@ -59757,7 +59776,7 @@ def _updateMoveFilePermissions(drive, user, i, count,
|
|
|
|
|
except (GAPI.notFound, GAPI.permissionNotFound,
|
|
|
|
|
GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
|
|
|
|
GAPI.fileNeverWritable, GAPI.badRequest, GAPI.cannotRemoveOwner, GAPI.cannotModifyInheritedTeamDrivePermission,
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded) as e:
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded, GAPI.cannotDeletePermission) as e:
|
|
|
|
|
entityActionFailedWarning(kvList, str(e), k, kcount)
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
|
|
|
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
|
|
|
|
@@ -61460,7 +61479,7 @@ def transferDrive(users):
|
|
|
|
|
if showRetentionMessages:
|
|
|
|
|
entityActionPerformed([Ent.USER, sourceUser, childFileType, childFileName, Ent.ROLE, ownerRetainRoleBody['role']], j, jcount)
|
|
|
|
|
except (GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
|
|
|
|
GAPI.badRequest, GAPI.sharingRateLimitExceeded, GAPI.cannotRemoveOwner) as e:
|
|
|
|
|
GAPI.badRequest, GAPI.sharingRateLimitExceeded, GAPI.cannotRemoveOwner, GAPI.cannotDeletePermission) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, sourceUser, childFileType, childFileName], str(e), j, jcount)
|
|
|
|
|
except GAPI.permissionNotFound:
|
|
|
|
|
entityDoesNotHaveItemWarning([Ent.USER, sourceUser, childFileType, childFileName, Ent.PERMISSION_ID, sourcePermissionId], j, jcount)
|
|
|
|
|
@@ -61513,7 +61532,7 @@ def transferDrive(users):
|
|
|
|
|
if showRetentionMessages:
|
|
|
|
|
entityActionPerformed([Ent.USER, sourceUser, childFileType, childFileName, Ent.ROLE, sourceUpdateRole['role']], j, jcount)
|
|
|
|
|
except (GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
|
|
|
|
GAPI.badRequest, GAPI.sharingRateLimitExceeded, GAPI.cannotRemoveOwner) as e:
|
|
|
|
|
GAPI.badRequest, GAPI.sharingRateLimitExceeded, GAPI.cannotRemoveOwner, GAPI.cannotDeletePermission) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, ownerUser, childFileType, childFileName], str(e), j, jcount)
|
|
|
|
|
except GAPI.permissionNotFound:
|
|
|
|
|
entityDoesNotHaveItemWarning([Ent.USER, ownerUser, childFileType, childFileName, Ent.PERMISSION_ID, sourcePermissionId], j, jcount)
|
|
|
|
|
@@ -61537,7 +61556,7 @@ def transferDrive(users):
|
|
|
|
|
if showRetentionMessages:
|
|
|
|
|
entityActionPerformed([Ent.USER, targetUser, childFileType, childFileName, Ent.ROLE, targetInsertBody['role']], j, jcount)
|
|
|
|
|
except (GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
|
|
|
|
GAPI.badRequest, GAPI.sharingRateLimitExceeded) as e:
|
|
|
|
|
GAPI.badRequest, GAPI.sharingRateLimitExceeded, GAPI.cannotDeletePermission) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, ownerUser, childFileType, childFileName], str(e), j, jcount)
|
|
|
|
|
except GAPI.invalidSharingRequest as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, ownerUser, childFileType, childFileName], Ent.TypeNameMessage(Ent.PERMISSION_ID, targetPermissionId, str(e)), j, jcount)
|
|
|
|
|
@@ -62280,7 +62299,7 @@ def claimOwnership(users):
|
|
|
|
|
entityActionPerformed([Ent.USER, oldOwner, entityType, fileDesc, Ent.ROLE, sourceRetainRoleBody['role']], l, lcount)
|
|
|
|
|
except GAPI.permissionNotFound:
|
|
|
|
|
entityDoesNotHaveItemWarning([Ent.USER, oldOwner, entityType, fileDesc, Ent.PERMISSION_ID, oldOwnerPermissionId], l, lcount)
|
|
|
|
|
except (GAPI.badRequest, GAPI.insufficientFilePermissions) as e:
|
|
|
|
|
except (GAPI.badRequest, GAPI.insufficientFilePermissions, GAPI.cannotDeletePermission) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, oldOwner, entityType, fileDesc], str(e), l, lcount)
|
|
|
|
|
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
|
|
|
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
|
|
|
|
@@ -63452,7 +63471,7 @@ def deleteDriveFileACLs(users, useDomainAdminAccess=False):
|
|
|
|
|
_updateSheetProtectedRangesACLchange(sheet, user, i, count, j, jcount, fileId, fileName, False, permission)
|
|
|
|
|
except (GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
|
|
|
|
GAPI.fileNeverWritable, GAPI.badRequest, GAPI.cannotRemoveOwner, GAPI.cannotModifyInheritedTeamDrivePermission,
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded) as e:
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded, GAPI.cannotDeletePermission) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, user, entityType, fileName], str(e), j, jcount)
|
|
|
|
|
except GAPI.notFound as e:
|
|
|
|
|
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, fileName], str(e), j, jcount)
|
|
|
|
|
@@ -63508,7 +63527,7 @@ def deletePermissions(users, useDomainAdminAccess=False):
|
|
|
|
|
entityActionPerformed([Ent.DRIVE_FILE_OR_FOLDER_ID, ri[RI_ENTITY], Ent.PERMISSION_ID, ri[RI_ITEM]], int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
|
|
|
except (GAPI.fileNotFound, GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.unknownError,
|
|
|
|
|
GAPI.badRequest, GAPI.cannotRemoveOwner, GAPI.cannotModifyInheritedTeamDrivePermission,
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded, GAPI.permissionNotFound,
|
|
|
|
|
GAPI.insufficientAdministratorPrivileges, GAPI.sharingRateLimitExceeded, GAPI.permissionNotFound, GAPI.cannotDeletePermission,
|
|
|
|
|
GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
|
|
|
|
entityActionFailedWarning([Ent.DRIVE_FILE_OR_FOLDER_ID, ri[RI_ENTITY], Ent.PERMISSION_ID, ri[RI_ITEM]], str(e), int(ri[RI_J]), int(ri[RI_JCOUNT]))
|
|
|
|
|
if int(ri[RI_J]) == int(ri[RI_JCOUNT]):
|
|
|
|
|
|