Subprocess & system.util.execute

  1. For logging, that will go to stderr (standard error output to the console) if you haven’t routed it to a logging file. execute() won’t show that, and subprocess can, but you have to get the subprocess code right to get any stderr messages back from subprocess into variables in Python that you can print.
  2. If you list your processes (“ps” command with appropriate arguments) you’ll be able to see what user Ignition is running as.

However, before going any further you might try to provide the full path to the python executable. The OS doesn’t always set up environment variables for execute() that include python3 in the path.

system.util.execute([“/path/to/python3”, “/home/pi/Nest/doIt.py” ])

If you’re using subprocess, to get standard printed results (stdout, not stderr) one option is to do something more like:

import subprocess
result = subprocess.check_output(“/path/to/python3”, “/path/to/python/program.py”)

Also, you could instead wrap your Python program in a local web service using flask or bottle. Some folks go that direction for portability. (I’ve done it myself for home projects with image capture from a Pi camera.) More info can be found here: Python, Jython, CPython, Libraries, Pip, and Python 2.7 vs 3 - A quick primer

2 Likes