<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def exec_command(args, env=None):
 """Convenience function that executes command and returns result. @param args: Tuple of command and arguments. @param env: Dictionary of environment variables. (Environment is not modified if None.) @return: Command output. """
 
    try:
        cmd = subprocess.Popen(args, 
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE, 
                               bufsize=buffSize,
                               env=env)
    except OSError, e:
        raise Exception("Execution of command failed.\n",
                        "  Command: %s\n  Error: %s" % (' '.join(args), str(e)))
    out, err = cmd.communicate(None)
    if cmd.returncode != 0:
        raise Exception("Execution of command failed with error code: %s\n%s\n" 
                        % (cmd.returncode, err))
    return out