def which(<EOL>exe=None, default_paths=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>):
def _is_executable_file_or_link(exe):<EOL><INDENT>return os.access(exe, os.X_OK) and (os.path.isfile(exe) or os.path.islink(exe))<EOL><DEDENT>if _is_executable_file_or_link(exe):<EOL><INDENT>return exe<EOL><DEDENT>search_path = (<EOL>os.environ.get('<STR_LIT>') and os.environ['<STR_LIT>'].split(os.pathsep) or list()<EOL>)<EOL>for default_path in default_paths:<EOL><INDENT>if default_path not in search_path:<EOL><INDENT>search_path.append(default_path)<EOL><DEDENT><DEDENT>os.environ['<STR_LIT>'] = os.pathsep.join(search_path)<EOL>for path in search_path:<EOL><INDENT>full_path = os.path.join(path, exe)<EOL>if _is_executable_file_or_link(full_path):<EOL><INDENT>return full_path<EOL><DEDENT><DEDENT>logger.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(exe, search_path)<EOL>)<EOL>return None<EOL>
Return path of bin. Python clone of /usr/bin/which.

    from salt.util - https://www.github.com/saltstack/salt - license apache

    :param exe: Application to search PATHs for.
    :type exe: str
    :param default_path: Application to search PATHs for.
    :type default_path: list
    :rtype: str