[svn r63137] a helper some basic remote info

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-20 14:41:43 +01:00
parent 764b85f23e
commit 8d8a73784c
2 changed files with 27 additions and 1 deletions

View File

@ -241,6 +241,17 @@ class Gateway(object):
chan.setcallback(callback) chan.setcallback(callback)
return chan.id 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 # High Level Interface
@ -354,6 +365,9 @@ class Gateway(object):
if self._requestqueue is not None: if self._requestqueue is not None:
self._requestqueue.put(None) self._requestqueue.put(None)
class RInfo:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
def getid(gw, cache={}): def getid(gw, cache={}):
name = gw.__class__.__name__ name = gw.__class__.__name__

View File

@ -441,6 +441,13 @@ class BasicRemoteExecution:
text = c1.receive() text = c1.receive()
assert text.find("execution disallowed") != -1 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): class BasicCmdbasedRemoteExecution(BasicRemoteExecution):
def test_cmdattr(self): def test_cmdattr(self):
assert hasattr(self.gw, '_cmd') assert hasattr(self.gw, '_cmd')
@ -480,7 +487,12 @@ def test_channel_endmarker_remote_killterm():
# assert x == 17 # assert x == 17
class TestPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution): 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): def test_chdir_separation(self):
old = py.test.ensuretemp('chdirtest').chdir() old = py.test.ensuretemp('chdirtest').chdir()
try: try: