def check_call(cmd, expected_retcode=0, stdin_str="", **kwargs):
  """Convenience function that is in the docs for subprocess but not
  installed on my system. Raises an Exception if the return code is not
  expected_retcode. Returns a tuple of strings, (stdout, stderr)."""
  try:
    if 'stdout' in kwargs or kwargs in 'stderr' or 'stdin' in kwargs:
      raise Exception("Don't pass stdout or stderr")

    # If a custom 'env' is in kwargs this will be passed to subprocess.Popen and
    # will prevent the subprocess from inheriting the parent's 'env'.
    # On Windows 7 we have to make sure that our custom 'env' contains
    # 'SystemRoot' as some code here is using os.urandom() which requires this
    # system variable. See review at http://codereview.appspot.com/4240085/ and
    # thread "is this a bug? no environment variables" at
    # http://www.gossamer-threads.com/lists/python/dev/878941
    if 'SystemRoot' in os.environ:
      if 'env' in kwargs:
        kwargs['env'].setdefault('SystemRoot', os.environ['SystemRoot'])

    p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE, stdin=subprocess.PIPE,
                         **kwargs)
    (out, err) = p.communicate(stdin_str)
    retcode = p.returncode
  except Exception, e:
    raise Exception("When running %s: %s" % (cmd, e))
  if retcode < 0:
    raise Exception(
        "Child '%s' was terminated by signal %d. Output:\n%s\n%s\n" %
        (cmd, -retcode, out, err))
  elif retcode != expected_retcode:
    raise Exception(
        "Child '%s' returned %d. Output:\n%s\n%s\n" %
        (cmd, retcode, out, err))
  return (out, err)
dataset/ETHPy150Open google/transitfeed/tests/util.py/check_call/swapped operands of `in`