Skip to content

Commit ac6502e

Browse files
committed
agentwrapper: try labgrid-python3 for agent environment
Allow probing of a labgrid-python3 executable and use that if available. This allows the setup of a distinct python environment with the necessary modules for agent operation. Since this is probed automatically raise a debug message in case labgrid-python3 is not found to aid in debugging. Signed-off-by: Rouven Czerwinski <rouven.czerwinski@linaro.org>
1 parent d3c08b1 commit ac6502e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

labgrid/util/agentwrapper.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,30 @@ def __init__(self, host=None):
6060
['rsync', '-e', ' '.join(ssh_opts), '-tq', agent,
6161
f'{host}:{agent_remote}'],
6262
)
63+
agent_python = "labgrid-python3" if subprocess.call(ssh_opgs + [host, '--', 'which', 'labgrid-python3']) else "python3"
64+
if agent_python == "python3":
65+
self.logger.debug(
66+
f"labgrid-python3 on {host} not found, using python3 which requires system installed python modules for agents"
67+
)
6368
self.agent = subprocess.Popen(
64-
ssh_opts + [host, '--', 'python3', agent_remote],
69+
ssh_opts + [host, '--', agent_python, agent_remote],
6570
stdin=subprocess.PIPE,
6671
stdout=subprocess.PIPE,
6772
start_new_session=True,
6873
)
6974
else:
7075
# run locally
7176
self.fdpass, remote_fdpass = socket.socketpair()
77+
agent_python = "labgrid-python3" if which("labgrid-python3") else "python3"
78+
if agent_python == "python3":
79+
self.logger.debug(
80+
"labgrid-python3 not found locally, using python3 which requires system installed python modules for agents"
81+
)
7282
with remote_fdpass:
7383
env = os.environ.copy()
7484
env["LG_FDPASS"] = str(remote_fdpass.fileno())
7585
self.agent = subprocess.Popen(
76-
['python3', agent],
86+
['agent-python', agent],
7787
stdin=subprocess.PIPE,
7888
stdout=subprocess.PIPE,
7989
env=env,

0 commit comments

Comments
 (0)