def execute_cmd(cmd, cwd=None, timeout=<NUM_LIT:5>):
p = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)<EOL>try:<EOL><INDENT>p.wait(timeout=timeout)<EOL><DEDENT>except subprocess.TimeoutExpired:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>stdout, stderr = p.stdout.read(), p.stderr.read()<EOL>if sys.version_info >= (<NUM_LIT:3>,):<EOL><INDENT>stdout, stderr = stdout.decode('<STR_LIT:utf-8>', errors='<STR_LIT:ignore>'), stderr.decode('<STR_LIT:utf-8>', errors='<STR_LIT:ignore>')<EOL><DEDENT>if p.returncode:<EOL><INDENT>raise ExecuteError('<STR_LIT>'.format(<EOL>'<STR_LIT:U+0020>'.join(cmd), p.returncode, stderr<EOL>))<EOL><DEDENT>else:<EOL><INDENT>return stdout, stderr<EOL><DEDENT><DEDENT>
Excecute command on thread

    :param cmd: Command to execute
    :param cwd: current working directory
    :return: None