Automation with Shortcuts and x-callback URLs¶
Pyto provides Shortcuts for running scripts and code. Shortcuts will open Pyto to execute the code and it’s not possible to retrieve the result. See x-callback URLs for getting callbacks.
Run Code with Arguments will execute the given code with the given arguments. Code can be executed in app or without leaving Shortcuts. If you uncheck
Run In App, the Shortcut will return the output of the code (stdout + stderr). When
Run In App is unchecked, the code will only have access to the standard library and
stdin cannot be sent.
Run Script with Arguments will execute the given script with the given arguments. Note that
Script is a file, and Shortcuts doesn’t provide a way to pick a file as a value. So the only ways to have a valid value passed to this Shortcut are by sharing a file with the Share Sheet and passing the input or by picking each time a script with the
Get file system Shortcut.
Pyto also provides a Shortcut for each script used with the app.
Pyto supports x-callback URLs for running scripts from other apps and getting the result.
Use x-callback URLs instead of Shortcuts if you need to get the output of the executed code. With this method you can only run code and not a script but you can use the runpy module for running scripts in a location like
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.
Pyto can also open external x-callback URLs with the xcallback module.