Find the full path to a .bat or .exe using the win32api module.
(cmd)
| 72 | |
| 73 | |
| 74 | def _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 | |
| 95 | def _system_body(p): |
nothing calls this directly
no outgoing calls
no test coverage detected