Show More
@@ -46,14 +46,21 b' except ImportError:' | |||||
46 | def find_cmd(cmd): |
|
46 | def find_cmd(cmd): | |
47 | """Find the full path to a .bat or .exe using the win32api module.""" |
|
47 | """Find the full path to a .bat or .exe using the win32api module.""" | |
48 | try: |
|
48 | try: | |
49 | import win32api |
|
49 | from win32api import SearchPath | |
50 | except ImportError: |
|
50 | except ImportError: | |
51 | raise ImportError('you need to have pywin32 installed for this to work') |
|
51 | raise ImportError('you need to have pywin32 installed for this to work') | |
52 | else: |
|
52 | else: | |
|
53 | PATH = os.environ['PATH'] | |||
|
54 | extensions = ['.exe', '.com', '.bat', '.py'] | |||
|
55 | path = None | |||
|
56 | for ext in extensions: | |||
53 | try: |
|
57 | try: | |
54 |
|
|
58 | path = SearchPath(PATH,cmd + ext)[0] | |
55 | except: |
|
59 | except: | |
56 | (path, offset) = win32api.SearchPath(os.environ['PATH'],cmd + '.bat') |
|
60 | pass | |
|
61 | if path is None: | |||
|
62 | raise OSError("command %r not found" % cmd) | |||
|
63 | else: | |||
57 | return path |
|
64 | return path | |
58 |
|
65 | |||
59 |
|
66 |
General Comments 0
You need to be logged in to leave comments.
Login now