From 8a76d7d6dee9d2e7abecd8e9b9401ef7f72e1315 2009-08-01 23:00:46 From: Fernando Perez Date: 2009-08-01 23:00:46 Subject: [PATCH] Add searching of .py files to find_cmd so Twisted's trial runner is found. Fix necessary for the test suite to run under win32. --- diff --git a/IPython/platutils_win32.py b/IPython/platutils_win32.py index d9f0ed3..9afc060 100644 --- a/IPython/platutils_win32.py +++ b/IPython/platutils_win32.py @@ -46,15 +46,22 @@ except ImportError: def find_cmd(cmd): """Find the full path to a .bat or .exe using the win32api module.""" try: - import win32api + from win32api import SearchPath except ImportError: raise ImportError('you need to have pywin32 installed for this to work') else: - try: - (path, offest) = win32api.SearchPath(os.environ['PATH'],cmd + '.exe') - except: - (path, offset) = win32api.SearchPath(os.environ['PATH'],cmd + '.bat') - return path + PATH = os.environ['PATH'] + extensions = ['.exe', '.com', '.bat', '.py'] + path = None + for ext in extensions: + try: + path = SearchPath(PATH,cmd + ext)[0] + except: + pass + if path is None: + raise OSError("command %r not found" % cmd) + else: + return path def get_long_path_name(path):