def _run_file_search_query(self,
query,
item_check,
fields="nextPageToken, files(id, name, kind, mimeType, md5Checksum, parents, shared)"):
nextPage = ""
try:
nextPage = ""
while nextPage is not None:
results = self.client.files().list(pageSize=1000,
q=query,
fields=fields,
pageToken=nextPage,
spaces="drive").execute()
items = results.get('files', [])
try:
nextPage = results.get('nextPageToken', None)
except:
nextPage = None
if not items:
logger.debug('No files found.')
else:
logger.debug('{} Files found.'.format(len(items)))
for item in items:
item_check(item)
except AccessTokenRefreshError:
# The AccessTokenRefreshError exception is raised if the credentials
# have been revoked by the user or they have expired.
logger.error('Unable to execute command. The access tokens have been'
' revoked by the user or have expired.')
评论列表
文章目录