I'm creating a hardening tool for popular versions of linux (RHEL, opensuse, ubuntu, etc.) I'm currently testing my code in an OpenSUSE environment using the zypper package manager.
I have this snippet of code:
message = subprocess.Popen(["/usr/bin/zypper","-n","install","vlock"],
stdout=subprocess.PIPE,shell = False)
details = message.stdout.readlines()
print message.poll()
This will install the package, in this case vlock, and then read in the output from the shell, and then print the success value which will either be a 0 or nonzero number. when I run this code in the python interpreter I can either print message.poll() or echo $? if I run the command outside of the interpreter and I get a 0 for success or a nonzero for failure as expected.
However when I actually run the full unit-test script from the shell:
sudo ./pkghelper.py
I print out the message.poll() value which is supposed to hold the same returned value from the finished process as either printing message.poll() or echo $? however instead of the value being an integer of 0 or nonzero, I get a value of None. Does anyone know why the value in the python interpreter is an integer and the value when running the script is None?!?! this is actually a major hinderance in the continuation of the development of the program and I can find anything online