Pythonista and Google Drive
shinyformica last edited by
So...I still don't understand it, but somehow only files which were created by Pythonista remain openable by Pythonista via Google Drive, unless I pass them through a third-party app like Documents.
For example, if I create a .py file in Pythonista, edit it, then copy it to Google Drive by sharing it from within Pythonista, or if I create it in iCloud Drive in Pythonista, and then use Apple Files to copy it to Google Drive, in both cases Pythonista will be able to open, read and import it from Google Drive.
However, if I just upload an identical .py file from somewhere else to Google Drive, Pythonista will show it greyed out in the file browser, and it won't be open/read/import-able. At least that's what I've discovered so far...I tried uploading a plain text file created with a tiny bit of boilerplate python in it:
import os def test(): print "hello" test()
Saved it as "test.py". And then uploaded to Google Drive from three different OSes: Linux, Windows NT and Windows 10. All three were not openable by Pythonista, but an identical bit of boilerplate made in Pythonista and then copied to Google Drive as above still works. I even tried a round-trip: downloaded the working file from Google Drive to Windows 10, edited, saved, then uploaded it again, and it stopped being openable. I think Google Drive is mucking around with the file types and preventing Pythonista from seeing these files as plain text/.py files somehow. Would love to know if others experience similar results.
@shinyformica What I explained (share from Files App / Google Drive) was true but I agree that my files come from Pythonista via Google API upload.
Thus I didn't try with files coming from anywhere else
Edit: I think that Files app use "Drive.file" as authorization
Edit: I told you I use pydrive to upload/download to/from Google Drive. I've checked my authorization and it is "drive". I remember that two years ago I got this kind of problems to not be able to read files coming from other sources and that I have had to update my setting from "drive.file" to "drive". It seems your problem is something like that but I don't know where, sorry 😐
go here to check authorizations you gave to applications
shinyformica last edited by shinyformica
@cvp thanks for those links, I think that's exactly what is going on. The Documents app definitely has "Drive" access, and I see no other apps authorized, which means it must be the default "iOS" authorization is "Drive.file" or lower. Which explains what I'm seeing.
I think I might just have to implement my own way of grabbing the files I need using pydrive, to avoid the two-step process via Documents.
I'll go find some good docs on pydrive and see how I would do it. What's your process for using pydrive to get files to and from Google Drive? I was hoping for a way to transfer an entire project directory structure back and forth, not individual files one by one.
@shinyformica I use pydrive for more than one year, without any problem.
The only difficulties I have had were to get access at beginning, solved due to big help of @jonb.
Your user, password and authorization scopes are stored in a settings file.
Once it's done, it is easy to use to, for instance, get a list of files in a folder, then download the files, etc...
You have methods like createfile, listfile, trash, upload, ...
@shinyformica You said "I see no other apps authorized"
Don't you see "My Drive" which is the Google Drive app?
If not, try first to install this app.
shinyformica last edited by
I definitely have the Google Drive app installed...without it, I wouldn't be able to see Google Drive in the locations when I hit "Open..." in Pythonista. But it is true that I am not seeing that exact interface you show above, anywhere...how do you get to that specific view of which apps are authorized? For me, neither the Settings->Manage Apps at drive.google.com, nor the app permissions details at myaccount.google.com/permissions show the same thing you see there. And none are showing the Drive app being given explicit permissions. So perhaps that is the issue?
@shinyformica in the Google Drive iOS app, you can get the same info
- left menu
- account at bottom
- manage your account (i translate from French)
- connection and security
- apps having access to your account