[svn r63139] make _rinfo() cache results by default
--HG-- branch : trunk
This commit is contained in:
parent
8d8a73784c
commit
265e7c5dc2
|
@ -241,16 +241,18 @@ class Gateway(object):
|
||||||
chan.setcallback(callback)
|
chan.setcallback(callback)
|
||||||
return chan.id
|
return chan.id
|
||||||
|
|
||||||
def _rinfo(self):
|
def _rinfo(self, update=False):
|
||||||
""" return some sys/env information from remote. """
|
""" return some sys/env information from remote. """
|
||||||
return RInfo(**self.remote_exec("""
|
if update or not hasattr(self, '_cache_rinfo'):
|
||||||
import sys, os
|
self._cache_rinfo = RInfo(**self.remote_exec("""
|
||||||
channel.send(dict(
|
import sys, os
|
||||||
executable = sys.executable,
|
channel.send(dict(
|
||||||
version_info = sys.version_info,
|
executable = sys.executable,
|
||||||
curdir = os.getcwd(),
|
version_info = sys.version_info,
|
||||||
))
|
cwd = os.getcwd(),
|
||||||
""").receive())
|
))
|
||||||
|
""").receive())
|
||||||
|
return self._cache_rinfo
|
||||||
|
|
||||||
# _____________________________________________________________________
|
# _____________________________________________________________________
|
||||||
#
|
#
|
||||||
|
|
|
@ -444,9 +444,22 @@ class BasicRemoteExecution:
|
||||||
def test__rinfo(self):
|
def test__rinfo(self):
|
||||||
rinfo = self.gw._rinfo()
|
rinfo = self.gw._rinfo()
|
||||||
assert rinfo.executable
|
assert rinfo.executable
|
||||||
assert rinfo.curdir
|
assert rinfo.cwd
|
||||||
assert rinfo.version_info
|
assert rinfo.version_info
|
||||||
|
old = self.gw.remote_exec("""
|
||||||
|
import os.path
|
||||||
|
cwd = os.getcwd()
|
||||||
|
channel.send(os.path.basename(cwd))
|
||||||
|
os.chdir('..')
|
||||||
|
""").receive()
|
||||||
|
try:
|
||||||
|
rinfo2 = self.gw._rinfo()
|
||||||
|
assert rinfo2.cwd == rinfo.cwd
|
||||||
|
rinfo3 = self.gw._rinfo(update=True)
|
||||||
|
assert rinfo3.cwd != rinfo2.cwd
|
||||||
|
finally:
|
||||||
|
self.gw._cache_rinfo = rinfo
|
||||||
|
self.gw.remote_exec("import os ; os.chdir(%r)" % old).waitclose()
|
||||||
|
|
||||||
class BasicCmdbasedRemoteExecution(BasicRemoteExecution):
|
class BasicCmdbasedRemoteExecution(BasicRemoteExecution):
|
||||||
def test_cmdattr(self):
|
def test_cmdattr(self):
|
||||||
|
@ -487,10 +500,11 @@ def test_channel_endmarker_remote_killterm():
|
||||||
# assert x == 17
|
# assert x == 17
|
||||||
|
|
||||||
class TestPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution):
|
class TestPopenGateway(PopenGatewayTestSetup, BasicRemoteExecution):
|
||||||
def test_remote_info_popen(self):
|
def test_rinfo_popen(self):
|
||||||
|
#rinfo = py.execnet.PopenGateway()._rinfo()
|
||||||
rinfo = self.gw._rinfo()
|
rinfo = self.gw._rinfo()
|
||||||
assert rinfo.executable == py.std.sys.executable
|
assert rinfo.executable == py.std.sys.executable
|
||||||
assert rinfo.curdir == py.std.os.getcwd()
|
assert rinfo.cwd == py.std.os.getcwd()
|
||||||
assert rinfo.version_info == py.std.sys.version_info
|
assert rinfo.version_info == py.std.sys.version_info
|
||||||
|
|
||||||
def test_chdir_separation(self):
|
def test_chdir_separation(self):
|
||||||
|
|
Loading…
Reference in New Issue