Automation with Shortcuts and x-callback URLs¶
Pyto provides Shortcuts for running scripts and code.
Shortcuts will open Pyto if the
Show Console parameter is enabled, if not, the code will run asynchronously in background and you can use the
Get Script Output action to wait for the script and get the output.
Run Code will execute the given code with the given arguments.
Run Script will execute the given script with the given arguments.
Run Command will execute the given Shell command.
Get Script Output will wait for a script to be executed and returns its output.
Pyto supports x-callback URLs for running scripts from other apps and getting the result.
With this method you can only run code and not a script but you can use the runpy module for running scripts.
This is the structure that should be used for running code:
code is the code to execute.
x-success is the URL to open when a script was executed successfully. Passes the output (stdout + stderr) to a
x-error is the URL to open when a script raised an exception. Passes the exception message to a
x-cancel is the URL to open when a script was stopped by the user or when the script raised
The Shortcuts app supports opening x-callback URLs. Here is an example of a Shortcut that shows the current Python version.