def try_run(commands):
 null = open(os.devnull, 'w')
 for command in commands:
  retcode = subprocess.call(command, stdout=null, shell=True, stderr=subprocess.STDOUT)
  if (retcode != 0):
   return False
 return True

def try_run ( commands ) : null = open ( os . devnull , 'w' ) for command in commands : retcode = subprocess . call ( command , stdout = null , shell = True , stderr = subprocess . STDOUT ) if ( retcode != 0 ) : return False return True
run a series of commands and only return true if all ran fine .