googledrive.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:cazador 作者: andrewsmhay 项目源码 文件源码
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.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号