Skip to content

file.GetContentFile(...) throws AttributeError as of version 1.4.11 #31

@aa-morgan

Description

@aa-morgan

As of this morning I am receiving the following error message when trying to call the file.GetContentFile(...) function.

Enter verification code: ··········
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-0a6757d6d3f6> in <module>()
     15 
     16 downloaded = drive.CreateFile({'id': gdrive_file_id})
---> 17 downloaded.GetContentFile('file.tar.gz')
     18 
     19 # ...
/usr/local/lib/python3.6/dist-packages/pydrive2/files.py in GetContentFile(self, filename, mimetype, remove_bom, callback)
    241     :raises: ApiRequestError, FileNotUploadedError, FileNotDownloadableError
    242     """
--> 243         files = self.auth.service.files()
    244         file_id = self.metadata.get("id") or self.get("id")
    245 
AttributeError: 'NoneType' object has no attribute 'files'

I fixed this error by reverting to version 1.4.10, so I assume some issue was introduced into 1.4.11.

For completeness here is the entire code used to reproduce the error,

from pydrive2.auth import GoogleAuth
from pydrive2.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

downloaded = drive.CreateFile({'id': "[GDRIVE_FILE_ID]"})
downloaded.GetContentFile('file.tar.gz')

The file is a .tar.gz file-type stored inside a Shared Google Drive directory.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions