(program)
| 1135 | |
| 1136 | # Finds the given executable 'program' in PATH. Operates like the Unix tool 'which'. |
| 1137 | def which(program): |
| 1138 | def is_exe(fpath): |
| 1139 | return os.path.isfile(fpath) and os.access(fpath, os.X_OK) |
| 1140 | |
| 1141 | fpath, fname = os.path.split(program) |
| 1142 | if fpath: |
| 1143 | if is_exe(program): |
| 1144 | return program |
| 1145 | else: |
| 1146 | exe_suffixes = [''] |
| 1147 | if WINDOWS and '.' not in fname: |
| 1148 | exe_suffixes = ['.exe', '.cmd', '.bat'] |
| 1149 | for path in os.environ['PATH'].split(os.pathsep): |
| 1150 | path = path.strip('"') |
| 1151 | exe_file = os.path.join(path, program) |
| 1152 | for ext in exe_suffixes: |
| 1153 | if is_exe(exe_file + ext): |
| 1154 | return exe_file + ext |
| 1155 | |
| 1156 | return None |
| 1157 | |
| 1158 | |
| 1159 | def win_get_default_browser(): |
no test coverage detected