From: W. Trevor King Date: Sat, 26 Jan 2013 22:46:55 +0000 (-0500) Subject: swc-installation-test-2.py: Handle unparsable versions gracefully X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1827af324a729ba201d8cfffc8c875441b1ffaa6;p=swc-setup-installation-test.git swc-installation-test-2.py: Handle unparsable versions gracefully This avoids raising NotImplementedError from my IPython 0.14.dev. We don't want to have to start ranking alpha, beta, dev, r6, etc., so just print the unparsable version and minimum version, and leave it to the student to decide if their version satisfies the condition. It's unlikely that students have such pre-/post-release software installed anyway. --- diff --git a/setup/swc-installation-test-2.py b/setup/swc-installation-test-2.py index 8122bfa..5f1bc37 100755 --- a/setup/swc-installation-test-2.py +++ b/setup/swc-installation-test-2.py @@ -228,6 +228,10 @@ class Dependency (object): def _get_version(self): raise NotImplementedError(self) + def _minimum_version_string(self): + return self.version_delimiter.join( + str(part) for part in self.minimum_version) + def _check_version(self, version, parsed_version=None): if not parsed_version: parsed_version = self._parse_version(version=version) @@ -235,9 +239,7 @@ class Dependency (object): raise DependencyError( checker=self, message='outdated version of {0}: {1} (need >= {2})'.format( - self.full_name(), version, - self.version_delimiter.join( - str(part) for part in self.minimum_version))) + self.full_name(), version, self._minimum_version_string())) def _parse_version(self, version): if not version: @@ -247,7 +249,13 @@ class Dependency (object): try: parsed_version.append(int(part)) except ValueError as e: - raise NotImplementedError((version, part))# from e + raise DependencyError( + checker=self, + message=( + 'unparsable {0!r} in version {1} of {2}, (need >= {3})' + ).format( + part, version, self.full_name(), + self._minimum_version_string()))# from e return tuple(parsed_version)