def execute(cmd, shell=False, poll_period=<NUM_LIT:1.0>, catch_out=False):
<EOL>log = logging.getLogger(__name__)<EOL>log.debug("<STR_LIT>", cmd)<EOL>stdout = "<STR_LIT>"<EOL>stderr = "<STR_LIT>"<EOL>if not shell and isinstance(cmd, string_types):<EOL><INDENT>cmd = shlex.split(cmd)<EOL><DEDENT>if catch_out:<EOL><INDENT>process = subprocess.Popen(<EOL>cmd,<EOL>shell=shell,<EOL>stderr=subprocess.PIPE,<EOL>stdout=subprocess.PIPE,<EOL>close_fds=True)<EOL><DEDENT>else:<EOL><INDENT>process = subprocess.Popen(cmd, shell=shell, close_fds=True)<EOL><DEDENT>stdout, stderr = process.communicate()<EOL>if stderr:<EOL><INDENT>log.error("<STR_LIT>", stderr)<EOL><DEDENT>if stdout:<EOL><INDENT>log.debug("<STR_LIT>", stdout)<EOL><DEDENT>returncode = process.returncode<EOL>log.debug("<STR_LIT>", returncode)<EOL>return returncode, stdout, stderr<EOL>
Execute UNIX command and wait for its completion

    Args:
        cmd (str or list): command to execute
        shell (bool): invoke inside shell environment
        catch_out (bool): collect process' output

    Returns:
        returncode (int): process return code
        stdout (str): collected process stdout (only if catch_out set to true)
        stderr (str): collected process stderr (only if catch_out set to true)