Run the given command (with shell=False) and return the output as a
  string. Strip the output of enclosing whitespace.
  If the return code is non-zero, throw GitInvocationError.

def check_call_out(command):
  """
  Run the given command (with shell=False) and return the output as a
  string. Strip the output of enclosing whitespace.
  If the return code is non-zero, throw GitInvocationError.
  """
  # start external command process
  p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

  # get outputs
  out, _ = p.communicate()

  # throw exception if process failed
  if p.returncode != 0:
    raise GitInvocationError, 'failed to run "%s"' % " ".join(command)

  return out.strip()