Using subprocess to read from stdout

I'm trying to run the following function with the hopes of reading back the response from stdout.

import subprocess as sp

def CHECK_ALL_OFF(ip):
    ch = 0
    s = ''
    for i in range(0, 10):
        for j in range(0, 16):
            ch = 100 * i + j
            s = 'snmpget -Oqv -v 2c -m +WIENER-CREATE_MIB -c public {_ip} outputStatus.u{_ch}'.format(
                    _ip = ip,
                    _ch = ch)

            raw = sp.Popen(s.split(), stdout=sp.PIPE, stderr=sp.PIPE)
            readback = sp.stdout.read()
            status = parse('"{_status} "\n', raw)['_status']

            if(status is None):   # Request timed out, which means the crate is off
                return True

            if(status.split()[0] == '80'):    # Some channel is still on ('00' is Off, and '01'-'07' are reserved for errors, also indicating it is off, 04 in particular)
                return False

    return True

When executing I get the following error in the script console:

Traceback (most recent call last):
  File "<input>", line 31, in <module>
  File "<input>", line 19, in CHECK_ALL_OFF
  File "C:\Users\lflader\.ignition\cache\gwlocalhost_8089\C0\pylib\subprocess.py", line 859, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\lflader\.ignition\cache\gwlocalhost_8089\C0\pylib\subprocess.py", line 1369, in _execute_child
    raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))
OSError: [Errno 2] No such file or directory

How can I go about diagnosing/fixing the OSError issue?

If snmpget is not in your paths I don't think just calling it like that would work but instead you would need the full path like C:\Some\Path\bin\snmpget. But I don't know that that is your issue here. Regardless I would suggest trying to use ProcessBuilder instead to get data out of calling a process, it seems to work a bit better - Procedure for installing python libraries from source - #16 by PGriffith

How does it go if you use the full path?

snmpget is in the paths of the gateway's server, but not on the computer running designer. I am actually port forwarding the connection to my gateway through an ssh tunnel. Could this be related?

Ohhh that will change everything then. Yes it is directly related. The computer running your designer, trying to run that, is looking for snmpget on the computer running designre. If snmpget is on your gateway server, you must run it on the gateway computer and the script in a gateway context.

You need to either use a message handler, or a gateway tag change event or something to run that on the gateway computer always. Then you can call that from any computer and it will run on the gateway no matter what computer is running designer.