def exec_command(args, env=None):
try:<EOL><INDENT>cmd = subprocess.Popen(args, <EOL>stdout=subprocess.PIPE,<EOL>stderr=subprocess.PIPE, <EOL>bufsize=buffSize,<EOL>env=env)<EOL><DEDENT>except OSError as e:<EOL><INDENT>raise Exception("<STR_LIT>",<EOL>"<STR_LIT>" % ('<STR_LIT:U+0020>'.join(args), str(e)))<EOL><DEDENT>out, err = cmd.communicate(None)<EOL>if cmd.returncode != <NUM_LIT:0>:<EOL><INDENT>raise Exception("<STR_LIT>" <EOL>% (cmd.returncode, err))<EOL><DEDENT>return out<EOL>
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.