I want to run nvidia-detect and capture the output in a list or even a string that I can do a string comparison of the output to what I require. I need to know if the system requires kmod-nvidia or kmod-nvidia-340xx.
I have searched and came up with two possible ways of capturing the output of nvidia-detect.
My initial code was:
test=str(os.system('nvidia-detect'))
print test
my output is: kmod-nvida 256
where 256 is the value of test.
So after searching I tried:
test2=subprocess.check_output('nvidia-detect', shell=True)
and get this error:
Traceback (most recent call last):
File "/home/emmdom/PycharmProjects/mycode/nvidia_update.py", line 8, in <module>
test2=subprocess.check_output('nvidia-detect')
AttributeError: 'module' object has no attribute 'check_output'