diff --git a/labgrid/util/agentwrapper.py b/labgrid/util/agentwrapper.py index fd23a4031..b40cda1e8 100644 --- a/labgrid/util/agentwrapper.py +++ b/labgrid/util/agentwrapper.py @@ -38,7 +38,7 @@ def __getattr__(self, name): class AgentWrapper: - def __init__(self, host=None): + def __init__(self, host=None, pyvirtenv=None): self.agent = None self.loaded = {} self.logger = logging.getLogger(f"ResourceExport({host})") @@ -58,8 +58,12 @@ def __init__(self, host=None): ['rsync', '-e', ' '.join(ssh_opts), '-tq', agent, f'{host}:{agent_remote}'], ) + select_virtenv = [] + if pyvirtenv is not None: + select_virtenv = f'source {pyvirtenv}/bin/activate &&'.split() + cmd = select_virtenv + ['python3', agent_remote] self.agent = subprocess.Popen( - ssh_opts + [host, '--', 'python3', agent_remote], + ssh_opts + [host, '--'] + cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, start_new_session=True,