diff --git a/py/execnet/gateway.py b/py/execnet/gateway.py index db941fc87..2c7df7e11 100644 --- a/py/execnet/gateway.py +++ b/py/execnet/gateway.py @@ -241,6 +241,17 @@ class Gateway(object): chan.setcallback(callback) return chan.id + def _rinfo(self): + """ return some sys/env information from remote. """ + return RInfo(**self.remote_exec(""" + import sys, os + channel.send(dict( + executable = sys.executable, + version_info = sys.version_info, + curdir = os.getcwd(), + )) + """).receive()) + # _____________________________________________________________________ # # High Level Interface @@ -354,6 +365,9 @@ class Gateway(object): if self._requestqueue is not None: self._requestqueue.put(None) +class RInfo: + def __init__(self, **kwargs): + self.__dict__.update(kwargs) def getid(gw, cache={}): name = gw.__class__.__name__ diff --git a/py/execnet/testing/test_gateway.py b/py/execnet/testing/test_gateway.py index 19efbbb81..70a5fb8a9 100644 --- a/py/execnet/testing/test_gateway.py +++ b/py/execnet/testing/test_gateway.py @@ -441,6 +441,13 @@ class BasicRemoteExecution: text = c1.receive() assert text.find("execution disallowed") != -1 + def test__rinfo(self): + rinfo = self.gw._rinfo() + assert rinfo.executable + assert rinfo.curdir + assert rinfo.version_info + + class BasicCmdbasedRemoteExecution(BasicRemoteExecution): def test_cmdattr(self): assert hasattr(self.gw, '_cmd') @@ -480,7 +487,12 @@ def test_channel_endmarker_remote_killterm(): # assert x == 17 class TestPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution): - #disabled = True + def test_remote_info_popen(self): + rinfo = self.gw._rinfo() + assert rinfo.executable == py.std.sys.executable + assert rinfo.curdir == py.std.os.getcwd() + assert rinfo.version_info == py.std.sys.version_info + def test_chdir_separation(self): old = py.test.ensuretemp('chdirtest').chdir() try: