Skip to content

Commit

Permalink
Provide remote Pyro5 compatibility for multiple remote objects
Browse files Browse the repository at this point in the history
This is a more rarely used case that we could cover with Pyro5
support as well. The advertised method remains in retrieving
multiple remote objects one by one using single remote object
getter and this one remains more manual and requiring of control
file implementation.

Signed-off-by: Plamen Dimitrov <[email protected]>
  • Loading branch information
pevogam committed Nov 15, 2024
1 parent df8359c commit fe4f431
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion aexpect/remote_door.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
from Pyro5 import server
# noinspection PyPackageRequirements
from Pyro5 import nameserver
NS_MODULE = "Pyro5.nameserver"
except ImportError:
# noinspection PyPackageRequirements,PyUnresolvedReferences
import Pyro4
Expand All @@ -92,10 +93,12 @@ def __init__(self):
# noinspection PyPackageRequirements
from Pyro4 import naming as nameserver
nameserver.start_ns = nameserver.startNS
NS_MODULE = "Pyro4.naming"

except ImportError:
logging.warning("Remote object backend (Pyro4) not found, some functionality"
" of the remote door will not be available")
NS_MODULE = ""

# NOTE: disable aexpect importing on the remote side if not available as the
# remote door can run code remotely without the requirement for the aexpect
Expand Down Expand Up @@ -848,7 +851,7 @@ def share_remote_objects(session, control_path, host="localhost", port=9090,

# setup remote objects server
LOG.info("Starting nameserver for the remote objects")
cmd = f"python -m Pyro4.naming -n {host} -p {port}"
cmd = f"python -m {NS_MODULE} -n {host} -p {port}"
session.cmd("START " + cmd if os_type == "windows" else cmd + " &")

LOG.info("Starting the server daemon for the remote objects")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_remote_door.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def test_share_remote_objects(self):
"""Test that a remote object can be shared properly and remotely."""
self.session = mock.MagicMock(name='session')
self.session.client = "ssh"
remote_door.NS_MODULE = "pyro.name.server"

control_file = os.path.join(remote_door.REMOTE_CONTROL_DIR,
"tmpxxxxxxxx.control")
Expand All @@ -234,7 +235,7 @@ def test_share_remote_objects(self):
else:
self.assertEqual(self.session.cmd.call_count, 1)
command = self.session.cmd.call_args[0][0]
self.assertEqual("python -m Pyro4.naming -n testhost -p 4242 &", command)
self.assertEqual(f"python -m {remote_door.NS_MODULE} -n testhost -p 4242 &", command)

def test_import_remote_exceptions(self):
"""Test that selected remote exceptions are properly imported and deserialized."""
Expand Down

0 comments on commit fe4f431

Please sign in to comment.