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.


    Running scripts saved in iCloud with Shortcuts

    Pythonista
    2
    4
    5023
    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.
    • holly
      holly last edited by

      I'm brushing off my rusty python and having a blast with Pythonista. I have a script now that works great when run in Pythonista, but I can figure out how to trigger it from Shortcuts. I've tried all sorts of variations on the path in the "Run Script" block in Shortcuts (the one with the Pythonista icon) and also several variations of urls with the Open URL block. Every time Pythonista says it can't find the file (and, lol, it opens the app with my script loaded behind the dialogue, sigh).

      If I write a helloworld in the "This iPhone" folder, no problem. I can call it from Shortcuts and it runs great. But the script I want to run lives in the "iCloud" folder, and I have it under version control and I edit it on several devices, so I don't want to move it if I don't have to. It also reads from and writes to files in its directory, which I want to be able to process in Jupyter later, so I really don't want to have to move all that into the "This iPhone" folder.

      I've been googling all day, and I'm down a rabbit hole with the os module trying to maybe import the script from a script in the This iPhone directory and I'm just getting syntax errors because, basically, I'm in territory well above my pay grade, so.. what am I missing? Is there any way to do this?

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

        @holly If I correctly understood

        pythonista3://script?action=run&root=icloud
        

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

          This is excellent! I got a similar (but not quite as thorough) response from another forum and managed to figure it out. My problem was that I was including the .py extension in my script name. When I took it out, it worked.

          And just for completeness, for anyone else who ends up here with a similar problem, my script is inside a directory in iCloud, so I also included the directory name, so:

          pythonista3://myDir/myScript?action=run&root=icloud
          

          Merci, @cvp !

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

            @holly Sorry but as my iPad is in French, some "print screens" show french texts like this "ouvrir url" in Shortcuts app.
            But Google Translate is our friend 😀

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