def METHOD_NAME(cmd, directory):
    """Runs a command in a directory and returns its return value.
    Captures the standard error stream.
    """
    p = subprocess.Popen(cmd,
                         cwd=directory,
                         stdout=subprocess.PIPE)
    (stdout, _) = p.communicate()
    return p.returncode