def METHOD_NAME(cmd_args, cwd=None, include_stderr=False, shell=False):
  """Runs a command and returns output as a string."""
  process = subprocess.Popen(
      cmd_args,
      stdin=subprocess.PIPE,
      stdout=subprocess.PIPE,
      stderr=subprocess.PIPE,
      shell=shell,
      cwd=cwd)
  output = process.communicate()
  if process.wait() != 0:
    print("Error while running the command!")
    print("\nOUTPUT:\n============")
    print(output[1].decode("utf-8"))
    print("============\n")
    raise Exception("cmd invocation FAILED: " + " ".join(cmd_args))
  rv = output[0].decode("utf-8")
  if include_stderr:
    rv = (rv + "\n" if rv else "") + output[1].decode("utf-8")
  return rv