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