Posts

Showing posts with the label subprocess

Issue with subprocess.check_output printing stderr, looking to implement error checking

Image
Issue with subprocess.check_output printing stderr, looking to implement error checking I am trying to beautify the output of different system commands, but since I am using a non Redhat based OS my program snags executing the rpm feature. Could someone give a nudge in the right direction, I would like to make this more Pythonic and implement error checking against the rpm function if not a RH based OS. def kernVer(kern1, kern2, kern3, kern4): if subprocess.check_output(["uname", "-a"]).decode('ascii').strip(): print ('x1b[6;30;42m' + '[✔] %s [✔]' % (kern1) + 'x1b[0m') if subprocess.check_output(["uname", "-mrs"]).decode('ascii').strip(): print ('x1b[6;30;42m' + '[✔] %s [✔]' % (kern2) + 'x1b[0m') if subprocess.check_output(["cat", "/proc/version"]).decode('ascii').strip(): print ('x1b[6;30;42m' + '[✔] %s'...