From dea04b39a3ea2adf55609002755caadeee6f7e11 Mon Sep 17 00:00:00 2001 From: Rouven Czerwinski Date: Wed, 10 Jun 2026 16:48:49 +0200 Subject: [PATCH] agentwrapper: allow setting the python interpreter Similar to the prefix, allow setup of the python interpreter to allow users to use their own python environments. Signed-off-by: Rouven Czerwinski --- doc/man/client.rst | 5 +++++ labgrid/util/agentwrapper.py | 3 ++- man/labgrid-client.1 | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/man/client.rst b/doc/man/client.rst index 309e36365..2ba70e832 100644 --- a/doc/man/client.rst +++ b/doc/man/client.rst @@ -80,6 +80,11 @@ LG_AGENT_PREFIX Add a prefix to ``.labgrid_agent_{agent_hash}.py`` allowing specification for where on the exporter it should be uploaded to. +LG_AGENT_PYTHON +~~~~~~~~~~~~~~~~~~~~~~ +Set the python interpreter to be used by the agentwrapper on the exporter, can +be either a full path or an executable. + Matches ------- Match patterns are used to assign a resource to a specific place. The format is: diff --git a/labgrid/util/agentwrapper.py b/labgrid/util/agentwrapper.py index c87b3e3a7..a1ae84c54 100644 --- a/labgrid/util/agentwrapper.py +++ b/labgrid/util/agentwrapper.py @@ -48,6 +48,7 @@ def __init__(self, host=None): os.path.abspath(os.path.dirname(__file__)), 'agent.py') agent_prefix = os.environ.get("LG_AGENT_PREFIX", "") + agent_python = os.environ.get("LG_AGENT_PYTHON", "python3") if host: # copy agent.py and run via ssh with open(agent, 'rb') as agent_fd: @@ -61,7 +62,7 @@ def __init__(self, host=None): f'{host}:{agent_remote}'], ) self.agent = subprocess.Popen( - ssh_opts + [host, '--', 'python3', agent_remote], + ssh_opts + [host, '--', agent_python, agent_remote], stdin=subprocess.PIPE, stdout=subprocess.PIPE, start_new_session=True, diff --git a/man/labgrid-client.1 b/man/labgrid-client.1 index dfc95b2e8..479b79ecf 100644 --- a/man/labgrid-client.1 +++ b/man/labgrid-client.1 @@ -1170,6 +1170,10 @@ unspecified, defaults to 30 seconds. .sp Add a prefix to \fB\&.labgrid_agent_{agent_hash}.py\fP allowing specification for where on the exporter it should be uploaded to. +.SS LG_AGENT_PYTHON +.sp +Set the python interpreter to be used by the agentwrapper on the exporter, can +be either a full path or an executable. .SH MATCHES .sp Match patterns are used to assign a resource to a specific place. The format is: