973 exe = os.path.join(dir, file) |
973 exe = os.path.join(dir, file) |
974 if os.access(exe, os.X_OK) and exe not in paths: |
974 if os.access(exe, os.X_OK) and exe not in paths: |
975 paths.append(exe) |
975 paths.append(exe) |
976 |
976 |
977 return paths |
977 return paths |
|
978 |
|
979 |
|
980 def getWindowsExecutablePath(file): |
|
981 """ |
|
982 Function to build the full path of an executable file from the environment |
|
983 on Windows platforms. |
|
984 |
|
985 First an executable with the extension .exe is searched for, thereafter one |
|
986 with the extension .bat and finally the given file name as is. The first |
|
987 match is returned. |
|
988 |
|
989 @param file filename of the executable to check (string) |
|
990 @return full executable name, if the executable file is accessible |
|
991 via the searchpath defined by the PATH environment variable, or an |
|
992 empty string otherwise. |
|
993 """ |
|
994 if os.path.isabs(file): |
|
995 if os.access(file, os.X_OK): |
|
996 return file |
|
997 else: |
|
998 return "" |
|
999 |
|
1000 filenames = [file + ".exe", file + ".bat", file] |
|
1001 |
|
1002 for filename in filenames: |
|
1003 cur_path = os.path.join(os.curdir, filename) |
|
1004 if os.path.exists(cur_path): |
|
1005 if os.access(cur_path, os.X_OK): |
|
1006 return cur_path |
|
1007 |
|
1008 path = os.getenv('PATH') |
|
1009 |
|
1010 # environment variable not defined |
|
1011 if path is None: |
|
1012 return "" |
|
1013 |
|
1014 dirs = path.split(os.pathsep) |
|
1015 for dir in dirs: |
|
1016 for filename in filenames: |
|
1017 exe = os.path.join(dir, filename) |
|
1018 if os.access(exe, os.X_OK): |
|
1019 return exe |
|
1020 |
|
1021 return "" |
978 |
1022 |
979 |
1023 |
980 def isExecutable(exe): |
1024 def isExecutable(exe): |
981 """ |
1025 """ |
982 Function to check, if a file is executable. |
1026 Function to check, if a file is executable. |