'Runs a command in an out-of-process shell.
Returns the output of that command. Working directory is self.root.'

def run_command_with_code(self, cmd, redirect_output=True, check_exit_code=True):

    if redirect_output:
        stdout = subprocess.PIPE
    else:
        stdout = None
    proc = subprocess.Popen(cmd, cwd=self.root, stdout=stdout)
    output = proc.communicate()[0]
    if (check_exit_code and (proc.returncode != 0)):
        self.die('Command    "%s"    failed.\n%s', '    '.join(cmd), output)
    return (output, proc.returncode)
