Is there a quiet version of subprocess.call?
Often that kind of chatter is coming on stderr, so you may want to silence that too. Since Python 3.3, subprocess.call
has this feature directly:
To suppress stdout or stderr, supply a value of DEVNULL.
Usage:
import subprocess
rc = subprocess.call(args, stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
If you are still on Python 2:
import os, subprocess
with open(os.devnull, 'wb') as shutup:
rc = subprocess.call(args, stdout=shutup, stderr=shutup)
Yes. Redirect its stdout
to /dev/null
.
process = subprocess.call(["my", "command"], stdout=open(os.devnull, 'wb'))