def gather(self, cmd):
if not isinstance(cmd, list):<EOL><INDENT>cmd_list = shlex.split(cmd)<EOL><DEDENT>else:<EOL><INDENT>cmd_list = cmd<EOL><DEDENT>cwd = pushd.Dir.getcwd()<EOL>cmd_info = '<STR_LIT>'.format(cwd, cmd_list)<EOL>self.logger.debug("<STR_LIT>".format(cmd_info))<EOL>proc = subprocess.Popen(<EOL>cmd_list, cwd=cwd,<EOL>stdout=subprocess.PIPE, stderr=subprocess.PIPE)<EOL>out, err = proc.communicate()<EOL>rc = proc.returncode<EOL>self.logger.debug(<EOL>"<STR_LIT>".<EOL>format(cmd_info, rc, out, err))<EOL>return rc, out, err<EOL>
Runs a command and returns rc,stdout,stderr as a tuple.

If called while the `Dir` context manager is in effect, guarantees that the
process is executed in that directory, even if it is no longer the current
directory of the process (i.e. it is thread-safe).

:param cmd: The command and arguments to execute
:return: (rc,stdout,stderr)