From: W. Trevor King Date: Thu, 21 Mar 2013 16:18:23 +0000 (-0400) Subject: swc-installation-test-2.py: Also look for extension-less paths X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=03b86fc8cdeb06a88d5c19c61556e7eb2db48560;p=swc-setup-installation-test.git swc-installation-test-2.py: Also look for extension-less paths Before this commit, CommandDependency checked self.command (with an optional extension determined by distutils). If that check failed to produce a version stream, we cycled through a list of additional hard-coded paths. For example: Notepad++ used: self.command = 'notepad++' self.paths = [ _os.path.join( _ROOT_PATH, 'Program Files', 'Notepad++', 'notepad++.exe'), ] Because some MS Windows commands lack the expected '.exe' extension, but are still present and detected by a number of shells, we should also look for the extension-less version of the command. I consolidated the _get_version_stream() logic to build a single list of paths and loop through it looking for success (and accumulating errors). This makes the handling of self.paths less of a special case, and sets us up for any additional path mangling we may need to support other poorly standardized OSes ;). --- diff --git a/setup/swc-installation-test-2.py b/setup/swc-installation-test-2.py index 3c1fc09..3778d7f 100755 --- a/setup/swc-installation-test-2.py +++ b/setup/swc-installation-test-2.py @@ -455,25 +455,22 @@ class CommandDependency (Dependency): raise NotImplementedError(self.version_stream) def _get_version_stream(self, **kwargs): - try: - return self._get_command_version_stream(**kwargs) - except DependencyError as e: - if self.paths: - or_errors = [e] - for path in self.paths: - try: - return self._get_command_version_stream( - command=path, **kwargs) - except DependencyError as e: - print('a') - or_errors.append(e) - raise DependencyError( - checker=self, - message='errors finding {0} version'.format( - self.full_name()), - causes=or_errors) - else: - raise + paths = [self.command + (self.exe_extension or '')] + if self.exe_extension: + paths.append(self.command) # also look at the extension-less path + if self.paths: + paths.extend(self.paths) + or_errors = [] + for path in paths: + try: + return self._get_command_version_stream(command=path, **kwargs) + except DependencyError as e: + or_errors.append(e) + raise DependencyError( + checker=self, + message='errors finding {0} version'.format( + self.full_name()), + causes=or_errors) def _get_version(self): version_stream = self._get_version_stream()