omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Pythonista and Google Drive

    Pythonista
    google drive
    2
    14
    10744
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • shinyformica
      shinyformica last edited by

      Is it possible to bring .py files over to pythonista from Google Drive? When I tap "Open..." under "External Files" in the main Pythonista panel, I get a Google Drive icon under the available locations, and I can navigate to and see files stored there...but only .txt files appear to be accessible, anything with .py or .zip is greyed out and can't be opened. I'm wondering if this is an iOS restriction, or a Google Drive restriction, or a Pythonista issue...just so I can determine if it's solvable at my end.

      I see this thread about setting up PyDrive in pythonista to allow programmatic access to Google Drive, but that's more complicated than what I need, really...I just want to be able to transfer .py files to and from Pythonista3 via Google Drive, which seemed like it might be possible...

      https://forum.omz-software.com/topic/5076/google-drive-support/1

      1 Reply Last reply Reply Quote 0
      • shinyformica
        shinyformica last edited by

        Just as an add-on to this post: if I use a third-party app like "Documents" (from the app store), which is a general file manager/preview app, I can get the files from Google Drive into that app, and then get them from that app into Pythonista without issue. So Google Drive -> Pythonista doesn't work, but Google Drive -> Documents -> Pythonista does. This makes me think it's some kind of iOS/Google Drive/Pythonista thing, where only certain file extensions and/or permissions are allowed? And somehow the Documents app gets those permissions, but Pythonista does not.

        cvp 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @shinyformica last edited by

          @shinyformica you can use the Apple Files app:

          • select Google Drive
          • select the .py file ( or long press)
          • share
          • run Pythonista script
          • import file
          1 Reply Last reply Reply Quote 0
          • shinyformica
            shinyformica last edited by

            @cvp I tried exactly that...but all .py files are greyed out and unselectable...so I can't get a share sheet for them. Also can't get a share sheet for the folder containing the files, though it is selectable - the share button doesn't become enabled when the folder is selected.

            Are you able to select a .py file in Google Drive from the Apple Files app and share it to Pythonista this way?
            Oddly, in the Google Drive app, I am able to hit the "..." button on each individual .py file and from that menu, choose "Open in", which gives a "Copy to Pythonista" option. So I can manually move items that way, just not from within Pythonista for some reason.

            The thing that's especially good about "Documents", is it lets Pythonista grab the entire containing folder, not just the individual files, which is much more convenient for a large project.

            1 Reply Last reply Reply Quote 0
            • shinyformica
              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.

              cvp 2 Replies Last reply Reply Quote 0
              • cvp
                cvp @shinyformica last edited by

                @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

                1 Reply Last reply Reply Quote 0
                • cvp
                  cvp @shinyformica last edited by cvp

                  @shinyformica please read this
                  Perhaps does Documents uses authorization "Drive" and Pythonista "Drive.file", that would explain the difference.

                  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

                  1 Reply Last reply Reply Quote 0
                  • shinyformica
                    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.

                    cvp 2 Replies Last reply Reply Quote 0
                    • cvp
                      cvp @shinyformica last edited by

                      @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, ...

                      1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @shinyformica last edited by

                        @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.

                        1 Reply Last reply Reply Quote 0
                        • shinyformica
                          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?

                          cvp 3 Replies Last reply Reply Quote 0
                          • cvp
                            cvp @shinyformica last edited by cvp

                            @shinyformica strange, it comes from https://myaccount.google.com/permissions

                            Edit: perhaps due to the fact I use the Google API

                            1 Reply Last reply Reply Quote 0
                            • cvp
                              cvp @shinyformica last edited by cvp

                              @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
                              1 Reply Last reply Reply Quote 0
                              • cvp
                                cvp @shinyformica last edited by cvp

                                @shinyformica To use pydrive, the best is to read this topic

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post
                                Powered by NodeBB Forums | Contributors