Find absolute path to executable cmd in a cross platform manner. This function tries to determine the full path to a command line program using `which` on Unix/Linux/OS X and `win32api` on Windows. Most of the time it will use the version that is first on the users `PATH`. Warning
(cmd)
| 26 | |
| 27 | |
| 28 | def find_cmd(cmd): |
| 29 | """Find absolute path to executable cmd in a cross platform manner. |
| 30 | |
| 31 | This function tries to determine the full path to a command line program |
| 32 | using `which` on Unix/Linux/OS X and `win32api` on Windows. Most of the |
| 33 | time it will use the version that is first on the users `PATH`. |
| 34 | |
| 35 | Warning, don't use this to find IPython command line programs as there |
| 36 | is a risk you will find the wrong one. Instead find those using the |
| 37 | following code and looking for the application itself:: |
| 38 | |
| 39 | import sys |
| 40 | argv = [sys.executable, '-m', 'IPython'] |
| 41 | |
| 42 | Parameters |
| 43 | ---------- |
| 44 | cmd : str |
| 45 | The command line program to look for. |
| 46 | """ |
| 47 | path = shutil.which(cmd) |
| 48 | if path is None: |
| 49 | raise FindCmdError('command could not be found: %s' % cmd) |
| 50 | return path |
| 51 | |
| 52 | |
| 53 | def abbrev_cwd(): |