Tries to find 'executable' in the directories listed in 'path'. A string listing directories separated by 'os.pathsep'; defaults to os.environ['PATH']. Returns the complete filename or None if not found.
(executable, path=None)
| 28 | |
| 29 | |
| 30 | def _find_executable(executable, path=None): |
| 31 | """Tries to find 'executable' in the directories listed in 'path'. |
| 32 | |
| 33 | A string listing directories separated by 'os.pathsep'; defaults to |
| 34 | os.environ['PATH']. Returns the complete filename or None if not found. |
| 35 | """ |
| 36 | if path is None: |
| 37 | path = os.environ['PATH'] |
| 38 | |
| 39 | paths = path.split(os.pathsep) |
| 40 | base, ext = os.path.splitext(executable) |
| 41 | |
| 42 | if (sys.platform == 'win32') and (ext != '.exe'): |
| 43 | executable = executable + '.exe' |
| 44 | |
| 45 | if not os.path.isfile(executable): |
| 46 | for p in paths: |
| 47 | f = os.path.join(p, executable) |
| 48 | if os.path.isfile(f): |
| 49 | # the file exists, we have a shot at spawn working |
| 50 | return f |
| 51 | return None |
| 52 | else: |
| 53 | return executable |
| 54 | |
| 55 | |
| 56 | def _read_output(commandstring, capture_stderr=False): |
no test coverage detected
searching dependent graphs…