From d3da6e2dbf207e33b39149a18d5e76025caac833 Mon Sep 17 00:00:00 2001 From: Bastian Krause Date: Mon, 18 Oct 2021 13:49:19 +0200 Subject: [PATCH] remote/client: fix forwarding of remote ports 'labgrid-client forward --remote' accidentally uses the variable 'localport', which is either not set at all (leading to a UnboundLocalError) if no --local/-L is set or is set to the LOCAL part of --local/-L, which is wrong. The LOCAL part of --remote/-R should be used instead. Fix that by using the correct variable 'local'. Note that the informational print used the correct variable already. Fixes: 51f3fe5d ("client: Add port forwarding") Signed-off-by: Bastian Krause --- CHANGES.rst | 3 +++ labgrid/remote/client.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9887dd301..e71c9b5b9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,6 +10,9 @@ Bug fixes in 0.5.0 - Fixed a bug where using ``labgrid-client io get`` always returned ``low`` when reading a ``sysfsgpio``. +- Fixed ``labgrid-client forward --remote``/``-R``, which used either the LOCAL + part of ``--local``/``-L`` accidentally (if specified) or raised an + UnboundLocalError. Breaking changes in 0.5.0 ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/labgrid/remote/client.py b/labgrid/remote/client.py index f01beb126..09e258fa9 100755 --- a/labgrid/remote/client.py +++ b/labgrid/remote/client.py @@ -1121,7 +1121,7 @@ def forward(self): print(f"Forwarding local port {localport:d} to remote port {remote:d}") for local, remote in self.args.remote: - stack.enter_context(drv.forward_remote_port(remote, localport)) + stack.enter_context(drv.forward_remote_port(remote, local)) print(f"Forwarding remote port {remote:d} to local port {local:d}") try: