Skip to content

Commit 9febbe9

Browse files
committed
Merging pull request 138
Signed-off-by: Lukáš Doktor <[email protected]> * github.com:autotest/aexpect: Provide remote Pyro5 compatibility for multiple remote objects
2 parents df8359c + b9563fc commit 9febbe9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

aexpect/remote_door.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
from Pyro5 import server
7878
# noinspection PyPackageRequirements
7979
from Pyro5 import nameserver
80+
NS_MODULE = "Pyro5.nameserver"
8081
except ImportError:
8182
# noinspection PyPackageRequirements,PyUnresolvedReferences
8283
import Pyro4
@@ -92,10 +93,12 @@ def __init__(self):
9293
# noinspection PyPackageRequirements
9394
from Pyro4 import naming as nameserver
9495
nameserver.start_ns = nameserver.startNS
96+
NS_MODULE = "Pyro4.naming"
9597

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

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

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

854857
LOG.info("Starting the server daemon for the remote objects")

tests/test_remote_door.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def test_share_remote_objects(self):
217217
"""Test that a remote object can be shared properly and remotely."""
218218
self.session = mock.MagicMock(name='session')
219219
self.session.client = "ssh"
220+
remote_door.NS_MODULE = "pyro.name.server"
220221

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

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

0 commit comments

Comments
 (0)