mirror of
https://github.com/GAM-team/GAM.git
synced 2026-06-28 09:51:36 +00:00
Update shared drive error handling
Some checks failed
Build and test GAM / build (build, 1, Build Intel Ubuntu Jammy, ubuntu-22.04) (push) Has been cancelled
Build and test GAM / build (build, 10, Build Intel Windows, windows-2022) (push) Has been cancelled
Build and test GAM / build (build, 11, Build Arm Windows, windows-11-arm) (push) Has been cancelled
Build and test GAM / build (build, 2, Build Intel Ubuntu Noble, ubuntu-24.04) (push) Has been cancelled
Build and test GAM / build (build, 3, Build Arm Ubuntu Noble, ubuntu-24.04-arm) (push) Has been cancelled
Build and test GAM / build (build, 4, Build Arm Ubuntu Jammy, ubuntu-22.04-arm) (push) Has been cancelled
Build and test GAM / build (build, 5, Build Intel StaticX Legacy, ubuntu-22.04, yes) (push) Has been cancelled
Build and test GAM / build (build, 6, Build Arm StaticX Legacy, ubuntu-22.04-arm, yes) (push) Has been cancelled
Build and test GAM / build (build, 7, Build Intel MacOS, macos-13) (push) Has been cancelled
Build and test GAM / build (build, 8, Build Arm MacOS 14, macos-14) (push) Has been cancelled
Build and test GAM / build (build, 9, Build Arm MacOS 15, macos-15) (push) Has been cancelled
Build and test GAM / build (test, 12, Test Python 3.10, ubuntu-24.04, 3.10) (push) Has been cancelled
Build and test GAM / build (test, 13, Test Python 3.11, ubuntu-24.04, 3.11) (push) Has been cancelled
Build and test GAM / build (test, 14, Test Python 3.12, ubuntu-24.04, 3.12) (push) Has been cancelled
Build and test GAM / build (test, 15, Test Python 3.14-dev, ubuntu-24.04, 3.14-dev) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Check for Google Root CA Updates / check-apis (push) Has been cancelled
Build and test GAM / merge (push) Has been cancelled
Build and test GAM / publish (push) Has been cancelled
Some checks failed
Build and test GAM / build (build, 1, Build Intel Ubuntu Jammy, ubuntu-22.04) (push) Has been cancelled
Build and test GAM / build (build, 10, Build Intel Windows, windows-2022) (push) Has been cancelled
Build and test GAM / build (build, 11, Build Arm Windows, windows-11-arm) (push) Has been cancelled
Build and test GAM / build (build, 2, Build Intel Ubuntu Noble, ubuntu-24.04) (push) Has been cancelled
Build and test GAM / build (build, 3, Build Arm Ubuntu Noble, ubuntu-24.04-arm) (push) Has been cancelled
Build and test GAM / build (build, 4, Build Arm Ubuntu Jammy, ubuntu-22.04-arm) (push) Has been cancelled
Build and test GAM / build (build, 5, Build Intel StaticX Legacy, ubuntu-22.04, yes) (push) Has been cancelled
Build and test GAM / build (build, 6, Build Arm StaticX Legacy, ubuntu-22.04-arm, yes) (push) Has been cancelled
Build and test GAM / build (build, 7, Build Intel MacOS, macos-13) (push) Has been cancelled
Build and test GAM / build (build, 8, Build Arm MacOS 14, macos-14) (push) Has been cancelled
Build and test GAM / build (build, 9, Build Arm MacOS 15, macos-15) (push) Has been cancelled
Build and test GAM / build (test, 12, Test Python 3.10, ubuntu-24.04, 3.10) (push) Has been cancelled
Build and test GAM / build (test, 13, Test Python 3.11, ubuntu-24.04, 3.11) (push) Has been cancelled
Build and test GAM / build (test, 14, Test Python 3.12, ubuntu-24.04, 3.12) (push) Has been cancelled
Build and test GAM / build (test, 15, Test Python 3.14-dev, ubuntu-24.04, 3.14-dev) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Check for Google Root CA Updates / check-apis (push) Has been cancelled
Build and test GAM / merge (push) Has been cancelled
Build and test GAM / publish (push) Has been cancelled
This commit is contained in:
@@ -52815,7 +52815,8 @@ def doSharedDriveSearch(drive, user, i, count, query, useDomainAdminAccess):
|
||||
pageMessage=getPageMessageForWhom(),
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
||||
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
||||
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE],
|
||||
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
||||
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
||||
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
||||
fields='nextPageToken,drives(id)', pageSize=100)
|
||||
if files:
|
||||
@@ -52823,7 +52824,7 @@ def doSharedDriveSearch(drive, user, i, count, query, useDomainAdminAccess):
|
||||
entityActionNotPerformedWarning([Ent.USER, user, Ent.DRIVE_FILE, None], emptyQuery(query, Ent.SHAREDDRIVE), i, count)
|
||||
except (GAPI.invalidQuery, GAPI.invalid):
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], invalidQuery(query), i, count)
|
||||
except (GAPI.queryRequiresAdminCredentials, GAPI.noListTeamDrivesAdministratorPrivilege) as e:
|
||||
except (GAPI.queryRequiresAdminCredentials, GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
||||
@@ -53126,7 +53127,11 @@ def _convertSharedDriveNameToId(drive, user, i, count, fileIdEntity, useDomainAd
|
||||
else:
|
||||
name = fileIdEntity['shareddrivename'].replace("'", "\\'")
|
||||
tdlist = callGAPIpages(drive.drives(), 'list', 'drives',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS,
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
||||
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
||||
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
||||
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES,
|
||||
GAPI.FILE_NOT_FOUND],
|
||||
useDomainAdminAccess=useDomainAdminAccess,
|
||||
q=f"name='{name}'",
|
||||
fields='nextPageToken,drives(id,name)', pageSize=100)
|
||||
@@ -53135,13 +53140,19 @@ def _convertSharedDriveNameToId(drive, user, i, count, fileIdEntity, useDomainAd
|
||||
if not tdlist:
|
||||
name = fileIdEntity['shareddrivename'].lower()
|
||||
feed = callGAPIpages(drive.drives(), 'list', 'drives',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS,
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
||||
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
||||
useDomainAdminAccess=useDomainAdminAccess,
|
||||
fields='nextPageToken,drives(id,name)', pageSize=100)
|
||||
tdlist = [td for td in feed if td['name'].lower() == name]
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_NAME, fileIdEntity['shareddrivename']], Msg.DOES_NOT_EXIST, i, count)
|
||||
return False
|
||||
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
||||
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges,
|
||||
GAPI.fileNotFound) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_NAME, fileIdEntity['shareddrivename']], str(e), i, count)
|
||||
return False
|
||||
jcount = len(tdlist)
|
||||
if jcount == 1:
|
||||
fileIdEntity['shareddrive']['driveId'] = tdlist[0]['id']
|
||||
@@ -53159,10 +53170,10 @@ def _getSharedDriveNameFromId(drive, sharedDriveId, useDomainAdminAccess=False):
|
||||
if not sharedDriveName:
|
||||
try:
|
||||
sharedDriveName = callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
useDomainAdminAccess=useDomainAdminAccess,
|
||||
driveId=sharedDriveId, fields='name')['name']
|
||||
except (GAPI.notFound, GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
||||
except (GAPI.fileNotFound, GAPI.notFound, GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
||||
sharedDriveName = TEAM_DRIVE
|
||||
GM.Globals[GM.MAP_SHAREDDRIVE_ID_TO_NAME][sharedDriveId] = sharedDriveName
|
||||
return sharedDriveName
|
||||
@@ -53183,7 +53194,7 @@ def _getDriveFileNameFromId(drive, fileId, combineTitleId=True, useDomainAdminAc
|
||||
if useDomainAdminAccess:
|
||||
try:
|
||||
result = callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
useDomainAdminAccess=useDomainAdminAccess,
|
||||
driveId=fileId, fields='name')
|
||||
if result:
|
||||
@@ -53191,7 +53202,7 @@ def _getDriveFileNameFromId(drive, fileId, combineTitleId=True, useDomainAdminAc
|
||||
if combineTitleId:
|
||||
fileName += '('+fileId+')'
|
||||
return (fileName, Ent.DRIVE_FOLDER, MIMETYPE_GA_FOLDER)
|
||||
except GAPI.notFound:
|
||||
except (GAPI.fileNotFound, GAPI.notFound):
|
||||
pass
|
||||
except (GAPI.forbidden, GAPI.internalError, GAPI.insufficientFilePermissions, GAPI.internalError,
|
||||
GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
||||
@@ -53357,7 +53368,7 @@ def _getDriveFileParentInfo(drive, user, i, count, body, parameters, emptyQueryO
|
||||
_setSearchArgs(result['driveId'])
|
||||
else:
|
||||
result = callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
driveId=parameters[DFA_SHAREDDRIVE_PARENTID], fields='id')
|
||||
parameters[DFA_KWARGS]['corpora'] = 'drive'
|
||||
parameters[DFA_KWARGS]['driveId'] = result['id']
|
||||
@@ -55584,7 +55595,7 @@ def initFileTree(drive, shareddrive, DLP, shareddriveFields, showParent, user, i
|
||||
f_file['parents'] = []
|
||||
fileTree[f_file['id']] = {'info': f_file, 'noParents': True, 'children': []}
|
||||
name = callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
driveId=fileId, fields='name')['name']
|
||||
fileTree[f_file['id']]['info']['name'] = f'{SHARED_DRIVES}/{name}'
|
||||
else:
|
||||
@@ -56770,12 +56781,12 @@ def printFileList(users):
|
||||
rootFolderId = fileIdEntity['shareddrive']['driveId']
|
||||
if not fileIdEntity['shareddrivename']:
|
||||
fileIdEntity['shareddrivename'] = callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND, GAPI.FILE_NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
driveId=rootFolderId, fields='name')['name']
|
||||
rootFolderName = fileIdEntity['shareddrivename']
|
||||
if not showParentsIdsAsList and DFF.parentsSubFields['isRoot']:
|
||||
DFF.parentsSubFields['rootFolderId'] = rootFolderId
|
||||
except (GAPI.notFound, GAPI.fileNotFound) as e:
|
||||
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, fileIdEntity['shareddrive']['driveId']], str(e), i, count)
|
||||
continue
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
@@ -65803,12 +65814,12 @@ def createSharedDrive(users, useDomainAdminAccess=False):
|
||||
while not created:
|
||||
try:
|
||||
callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
useDomainAdminAccess=useDomainAdminAccess,
|
||||
driveId=driveId, fields='id')
|
||||
created = True
|
||||
break
|
||||
except GAPI.notFound as e:
|
||||
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
||||
retry += 1
|
||||
if retry > errorRetries:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count)
|
||||
@@ -66097,14 +66108,14 @@ def infoSharedDrive(users, useDomainAdminAccess=False):
|
||||
try:
|
||||
driveId = fileIdEntity['shareddrive']['driveId']
|
||||
shareddrive = callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
useDomainAdminAccess=useDomainAdminAccess,
|
||||
driveId=driveId, fields=fields)
|
||||
role = _getSharedDriveRole(shareddrive)
|
||||
if role:
|
||||
shareddrive['role'] = role if not guiRoles else SHAREDDRIVE_API_GUI_ROLES_MAP[role]
|
||||
_showSharedDrive(user, shareddrive, i, count, FJQC)
|
||||
except GAPI.notFound as e:
|
||||
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE_ID, driveId], str(e), i, count)
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
userDriveServiceNotEnabledWarning(user, str(e), i, count)
|
||||
@@ -66258,11 +66269,13 @@ def printShowSharedDrives(users, useDomainAdminAccess=False):
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
||||
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
||||
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
||||
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES,
|
||||
GAPI.FILE_NOT_FOUND],
|
||||
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
||||
fields='*', pageSize=100)
|
||||
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
||||
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.fileNotFound) as e:
|
||||
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges,
|
||||
GAPI.fileNotFound) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
||||
continue
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
@@ -66597,8 +66610,10 @@ def printShowSharedDriveACLs(users, useDomainAdminAccess=False):
|
||||
if userdrive is not None:
|
||||
try:
|
||||
feed = callGAPIpages(userdrive.drives(), 'list', 'drives',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS,
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID, GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE],
|
||||
fields='nextPageToken,drives(id,name,createdTime,orgUnitId)', pageSize=100)
|
||||
except (GAPI.invalid, GAPI.noListTeamDrivesAdministratorPrivilege):
|
||||
pass
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy):
|
||||
pass
|
||||
if feed is None:
|
||||
@@ -66613,10 +66628,12 @@ def printShowSharedDriveACLs(users, useDomainAdminAccess=False):
|
||||
pageMessage=pageMessage,
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
||||
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
||||
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE],
|
||||
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
||||
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
||||
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
||||
fields='nextPageToken,drives(id,name,createdTime,orgUnitId)', pageSize=100)
|
||||
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials, GAPI.noListTeamDrivesAdministratorPrivilege) as e:
|
||||
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
||||
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
||||
continue
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
@@ -66847,11 +66864,11 @@ def printSharedDriveOrganizers(users, useDomainAdminAccess=False):
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.INVALID_QUERY, GAPI.INVALID,
|
||||
GAPI.QUERY_REQUIRES_ADMIN_CREDENTIALS,
|
||||
GAPI.NO_LIST_TEAMDRIVES_ADMINISTRATOR_PRIVILEGE,
|
||||
GAPI.FILE_NOT_FOUND],
|
||||
GAPI.INSUFFICIENT_ADMINISTRATOR_PRIVILEGES],
|
||||
q=query, useDomainAdminAccess=useDomainAdminAccess,
|
||||
fields='nextPageToken,drives(id,name,createdTime,orgUnitId)', pageSize=100)
|
||||
except (GAPI.invalidQuery, GAPI.invalid, GAPI.queryRequiresAdminCredentials,
|
||||
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.fileNotFound) as e:
|
||||
GAPI.noListTeamDrivesAdministratorPrivilege, GAPI.insufficientAdministratorPrivileges) as e:
|
||||
entityActionFailedWarning([Ent.USER, user, Ent.SHAREDDRIVE, None], str(e), i, count)
|
||||
continue
|
||||
except (GAPI.serviceNotAvailable, GAPI.authError, GAPI.domainPolicy) as e:
|
||||
@@ -66865,7 +66882,7 @@ def printSharedDriveOrganizers(users, useDomainAdminAccess=False):
|
||||
j +=1
|
||||
try:
|
||||
feed.append(callGAPI(drive.drives(), 'get',
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.NOT_FOUND],
|
||||
throwReasons=GAPI.DRIVE_USER_THROW_REASONS+[GAPI.FILE_NOT_FOUND, GAPI.NOT_FOUND],
|
||||
useDomainAdminAccess=useDomainAdminAccess,
|
||||
driveId=driveId, fields='id,name,createdTime,orgUnitId'))
|
||||
except (GAPI.fileNotFound, GAPI.notFound) as e:
|
||||
|
||||
Reference in New Issue
Block a user