def command_succeeds(cmd):
 import subprocess
 with open(os.devnull, 'w') as f:
  try:
   subprocess.Popen(cmd, stdout=f, stderr=subprocess.STDOUT).wait()
  except OSError:
   return False
 return True

def command_succeeds ( cmd ) : import subprocess with open ( os . devnull , 'w' ) as f : try : subprocess . Popen ( cmd , stdout = f , stderr = subprocess . STDOUT ) . wait ( ) except OSError : return False return True
runs the command .