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

Function _find_cmd

IPython/utils/_process_win32.py:74–92  ·  view source on GitHub ↗

Find the full path to a .bat or .exe using the win32api module.

(cmd)

Source from the content-addressed store, hash-verified

72
73
74def _find_cmd(cmd):
75 """Find the full path to a .bat or .exe using the win32api module."""
76 try:
77 from win32api import SearchPath
78 except ImportError:
79 raise ImportError('you need to have pywin32 installed for this to work')
80 else:
81 PATH = os.environ['PATH']
82 extensions = ['.exe', '.com', '.bat', '.py']
83 path = None
84 for ext in extensions:
85 try:
86 path = SearchPath(PATH, cmd, ext)[0]
87 except:
88 pass
89 if path is None:
90 raise OSError("command %r not found" % cmd)
91 else:
92 return path
93
94
95def _system_body(p):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected