def executable_exists(executable): if not executable: return False if type(executable) == list: executable = executable[0] env = desktop.lib.i18n.make_utf8_env() path = env.get("PATH", os.defpath) path = [os.path.normpath(item) for item in path.strip().strip(os.pathsep).split(os.pathsep)] for item in path: potential_executable = os.path.join(item, executable) if os.access(potential_executable, os.F_OK | os.X_OK): return True return False
def executable(path): """Test for executable file.""" return os.access(path, os.X_OK)