platypush/plugins/google/drive/__init__.py
def download(self, file_id: str, path: str) -> str:
        """
        Download a Google Drive file locally.

        :param file_id: Path of the file to upload.
        :param path: Path of the file to upload.
        :return: The local file path.
        """
        # noinspection PyPackageRequirements
        from googleapiclient.http import MediaIoBaseDownload

        service = self.get_service()
        request = service.files().get_media(fileId=file_id)
        path = os.path.abspath(os.path.expanduser(path))
        if os.path.isdir(path):
            name = service.files().get(fileId=file_id).execute().get('name')
            path = os.path.join(path, name)

        fh = io.BytesIO()
        downloader = MediaIoBaseDownload(fh, request)
        done = False

        while not done:
            status, done = downloader.next_chunk()
            self.logger.info('Download progress: {}%'.format(status.progress()))

        with open(path, 'wb') as f:
            f.write(fh.getbuffer().tobytes())
        return path

        Download a Google Drive file locally.

        :param file_id: Path of the file to upload.
        :param path: Path of the file to upload.
        :return: The local file path.
        
Download a Google Drive file locally.
Download a Google Drive file locally .
def download(self, file_id: str, path: str) -> str:
        from googleapiclient.http import MediaIoBaseDownload
        service = self.get_service()
        request = service.files().get_media(fileId=file_id)
        path = os.path.abspath(os.path.expanduser(path))
        if os.path.isdir(path):
            name = service.files().get(fileId=file_id).execute().get('name')
            path = os.path.join(path, name)
        fh = io.BytesIO()
        downloader = MediaIoBaseDownload(fh, request)
        done = False
        while not done:
            status, done = downloader.next_chunk()
            self.logger.info('Download progress: {}%'.format(status.progress()))
        with open(path, 'wb') as f:
            f.write(fh.getbuffer().tobytes())
        return path
def download ( self , file_id : str , path : str ) -> str : from googleapiclient . http import MediaIoBaseDownload service = self . get_service ( ) request = service . files ( ) . get_media ( fileId = file_id ) path = os . path . abspath ( os . path . expanduser ( path ) ) if os . path . isdir ( path ) : name = service . files ( ) . get ( fileId = file_id ) . execute ( ) . get ( 'name' ) path = os . path . join ( path , name ) fh = io . BytesIO ( ) downloader = MediaIoBaseDownload ( fh , request ) done = False while not done : status , done = downloader . next_chunk ( ) self . logger . info ( 'Download progress: {}%' . format ( status . progress ( ) ) ) with open ( path , 'wb' ) as f : f . write ( fh . getbuffer ( ) . tobytes ( ) ) return path
Download a Google Drive file locally.
Download a Google Drive file locally .
"""
        Download a Google Drive file locally.

        :param file_id: Path of the file to upload.
        :param path: Path of the file to upload.
        :return: The local file path.
        """ # noinspection PyPackageRequirements
The local file path.
The local file path .
self
file_id
str
Path of the file to upload.
Path of the file to upload .
path
str
Path of the file to upload.
Path of the file to upload .