def run_command_with_code(cmd, redirect_output=True, check_exit_code=True):
 if redirect_output:
  stdout = subprocess.PIPE
 else:
  stdout = None
 proc = subprocess.Popen(cmd, cwd=ROOT, stdout=stdout)
 output = proc.communicate()[0]
 if (check_exit_code and (proc.returncode != 0)):
  die('Command "%s" failed.\n%s', ' '.join(cmd), output)
 return (output, proc.returncode)

def run_command_with_code ( cmd , redirect_output = True , check_exit_code = True ) : if redirect_output : stdout = subprocess . PIPE else : stdout = None proc = subprocess . Popen ( cmd , cwd = ROOT , stdout = stdout ) output = proc . communicate ( ) [ 0 ] if ( check_exit_code and ( proc . returncode != 0 ) ) : die ( 'Command "%s" failed.\n%s' , ' ' . join ( cmd ) , output ) return ( output , proc . returncode )
runs a command in an out-of-process shell .