def exec_command(attr, cmd):
    """Runs a subproc to calculate a package attribute.
    """
    import subprocess

    p = popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = p.communicate()

    if p.returncode:
        from rez.exceptions import InvalidPackageError
        raise InvalidPackageError(
            "Error determining package attribute '%s':\n%s" % (attr, err))

    return out.strip(), err.strip()
Runs a subproc to calculate a package attribute.