Skip to content

Commit 7282541

Browse files
committed
remote/exporter: refactor ser2net version check
Turn the version variable into a tuple which consists of (major, minor, micro). Convert the exit code check to use tuples instead of strings and also correct the version check for the YAML configuration to use a tuple. No functional changes intended. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
1 parent e5ace1a commit 7282541

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

labgrid/remote/exporter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,16 @@ def _start(self, start_params):
233233
# Ser2net has switched to using YAML format at version 4.0.0.
234234
result = subprocess.run([self.ser2net_bin, "-v"], capture_output=True, text=True)
235235
_, _, version = str(result.stdout).split(" ")
236-
major_version = version.split(".")[0]
236+
version = tuple(map(int, version.strip().split(".")))
237237

238238
# There is a bug in ser2net between 4.4.0 and 4.6.1 where it
239239
# returns 1 on a successful call to 'ser2net -v'. We don't want
240240
# a failure because of this, so raise an error only if ser2net
241241
# is not one of those versions.
242-
if version.strip() not in ["4.4.0", "4.5.0", "4.5.1", "4.6.0", "4.6.1"] and result.returncode == 1:
242+
if version not in [(4, 4, 0), (4, 5, 0), (4, 5, 1), (4, 6, 0), (4, 6, 1)] and result.returncode == 1:
243243
raise ExporterError(f"ser2net {version} returned a nonzero code during version check.")
244244

245-
if int(major_version) >= 4:
245+
if version >= (4, 0, 0):
246246
cmd = [
247247
self.ser2net_bin,
248248
"-d",

0 commit comments

Comments
 (0)