4 ms·
To execute a Python script as a Mail rule action? Horrible. You need to write an AppleScript which calls `do shell script` to run the Python script, passing da
by hhas 4y ago
To execute a Python script as a Mail rule action? Horrible.
You need to write an AppleScript which calls `do shell script` to run the Python script, passing data to the Python script via argv or temp file (`do shell script` doesn’t support stdin so you’ve got the added pain of ensuring correct shell quoting and/or file wrangling).
Also, if if you want to pass anything more complex than short simple strings to the Python script then you’ll need to encode that data into XML or JSON which Python can trivially parse out of the box. AS’s own stdlib support is dismal, however, so you’ll need to roll your own code or rummage around online for third-party AS libraries to encode the Mail data in one of those formats.
Be aware too that `do shell script` does not read your `.zprofile` environment settings, so you’ll have to specify the full path to your `python3` interpreter wherever you’ve got that installed.