|
3 | 3 |
|
4 | 4 | from flask_babel import gettext |
5 | 5 | from octoprint.util.version import get_comparable_version |
| 6 | +from packaging.version import InvalidVersion |
6 | 7 |
|
7 | 8 | from . import AuthorCheck, Check, NegativeCapCheck, Severity |
8 | 9 |
|
@@ -94,7 +95,11 @@ def received(self, line): |
94 | 95 |
|
95 | 96 | def _broken_version(self, line): |
96 | 97 | version_str = line[len(self.VERSION) :] |
97 | | - version = get_comparable_version(version_str, base=True) |
| 98 | + try: |
| 99 | + version = get_comparable_version(version_str, base=True) |
| 100 | + except InvalidVersion: |
| 101 | + version = None |
| 102 | + |
98 | 103 | if version is not None and version < self.FIXED_VERSION: |
99 | 104 | return True |
100 | 105 | else: |
@@ -161,11 +166,17 @@ class MalyanM200Check(Check): |
161 | 166 | FIXED_VERSION = get_comparable_version("4.0") |
162 | 167 |
|
163 | 168 | def m115(self, name, data): |
| 169 | + try: |
| 170 | + version = get_comparable_version(data.get("VER", "0")) |
| 171 | + except InvalidVersion: |
| 172 | + version = None |
| 173 | + |
164 | 174 | self._triggered = ( |
165 | 175 | name |
166 | 176 | and name.lower().startswith("malyan") |
167 | 177 | and data.get("MODEL") == "M200" |
168 | | - and get_comparable_version(data.get("VER", "0")) < self.FIXED_VERSION |
| 178 | + and version is not None |
| 179 | + and version < self.FIXED_VERSION |
169 | 180 | ) |
170 | 181 | self._active = False |
171 | 182 |
|
@@ -224,7 +235,10 @@ def _extract_repetier_version(self, name): |
224 | 235 | version = None |
225 | 236 | if "_" in name: |
226 | 237 | _, version = name.split("_", 1) |
227 | | - version = get_comparable_version(version, base=True) |
| 238 | + try: |
| 239 | + version = get_comparable_version(version, base=True) |
| 240 | + except InvalidVersion: |
| 241 | + pass |
228 | 242 | return version |
229 | 243 |
|
230 | 244 |
|
|
0 commit comments