MCPcopy Create free account
hub / github.com/ipython/ipython / find_cmd

Function find_cmd

IPython/utils/process.py:28–50  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

26
27
28def 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
53def abbrev_cwd():

Callers 6

test_find_cmd_lsFunction · 0.90
test_find_cmd_pythonwFunction · 0.90
test_script_defaultsFunction · 0.90
latex_to_png_dvipngFunction · 0.90
kpsewhichFunction · 0.90

Calls 1

FindCmdErrorClass · 0.85

Tested by 4

test_find_cmd_lsFunction · 0.72
test_find_cmd_pythonwFunction · 0.72
test_script_defaultsFunction · 0.72