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?