import subprocess
# Make a check for shell call. Don't mind on `ls` out, its an articat of glot.io
print "check `ls -l`: {0}".format(subprocess.check_call(["ls", "-l"]))
# And now lets demonstrate the exception rises on called process error
try:
# When you use shell=True it actually equivalent to:
# /bin/sh -c *args
print "check `exit 1`: {0}".format(subprocess.check_call("exit 1", shell=True))
except subprocess.CalledProcessError as e:
print "Error: {0}".format(e)