Skip to content

Commit 0969865

Browse files
Thomas PrestonEmantor
authored andcommitted
exporter: Check /usr/sbin for ser2net
On Debian, the ser2net binary is installed at /usr/sbin/ser2net and it can be run by any user. Since this isn't on the users PATH, we should attempt to use it when failing to find a ser2net binary, before falling back to /usr/bin/ser2net. Signed-off-by: Thomas Preston <thomas.preston@codethink.co.uk>
1 parent 93059af commit 0969865

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ New Features in 0.4.0
1717
make them easier distinguishable from pytest's "PASSED" output.
1818
- Network controlled relay providing GET/PUT based REST API
1919
- Improved LG_PROXY documentation in docs/usage.rst.
20+
- Exporter now checks /usr/sbin/ser2net for SerialPortExport
2021

2122
Bug fixes in 0.4.0
2223
~~~~~~~~~~~~~~~~~~

labgrid/remote/exporter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77
import sys
88
import os
9+
import os.path
910
import time
1011
import traceback
1112
import shutil
@@ -191,8 +192,12 @@ def __attrs_post_init__(self):
191192
self.port = None
192193
self.ser2net_bin = shutil.which("ser2net")
193194
if self.ser2net_bin is None:
194-
warnings.warn("ser2net binary not found, falling back to /usr/bin/ser2net")
195-
self.ser2net_bin = "/usr/bin/ser2net"
195+
if os.path.isfile("/usr/sbin/ser2net"):
196+
self.ser2net_bin = "/usr/sbin/ser2net"
197+
198+
if self.ser2net_bin is None:
199+
warnings.warn("ser2net binary not found, falling back to /usr/bin/ser2net")
200+
self.ser2net_bin = "/usr/bin/ser2net"
196201

197202
def __del__(self):
198203
if self.child is not None:

0 commit comments

Comments
 (0)