[svn r37780] simplifying code a bit (but test_confusion* for Ssh still fails)

--HG--
branch : trunk
This commit is contained in:
hpk 2007-02-02 00:57:55 +01:00
parent cf7e2d7c28
commit 3634701598
4 changed files with 9 additions and 17 deletions

View File

@ -31,12 +31,12 @@ debug = 0 # open('/tmp/execnet-debug-%d' % os.getpid() , 'wa')
sysex = (KeyboardInterrupt, SystemExit)
class Gateway(object):
num_worker_threads = 2
ThreadOut = ThreadOut
remoteaddress = ""
def __init__(self, io, startcount=2, maxthreads=None):
global registered_cleanup
self._execpool = WorkerPool()
self._execpool = WorkerPool(maxthreads=maxthreads)
## self.running = True
self.io = io
self._outgoing = Queue.Queue()
@ -50,7 +50,7 @@ class Gateway(object):
sender = self.thread_sender)
def __repr__(self):
addr = self._getremoteaddress()
addr = self.remoteaddress
if addr:
addr = '[%s]' % (addr,)
else:
@ -67,9 +67,6 @@ class Gateway(object):
return "<%s%s %s/%s (%s active channels)>" %(
self.__class__.__name__, addr, r, s, i)
def _getremoteaddress(self):
return None
## def _local_trystopexec(self):
## self._execpool.shutdown()

View File

@ -136,9 +136,7 @@ class SocketGateway(InstallableGateway):
sock.connect((host, port))
io = inputoutput.SocketIO(sock)
super(SocketGateway, self).__init__(io=io)
def _getremoteaddress(self):
return '%s:%d' % (self.host, self.port)
self.remoteaddress = '%s:%d' % (self.host, self.port)
def remote_install(cls, gateway, hostport=None):
""" return a connected socket gateway through the
@ -167,7 +165,7 @@ class SocketGateway(InstallableGateway):
class SshGateway(PopenCmdGateway):
def __init__(self, sshaddress, remotepython='python', identity=None):
self.sshaddress = sshaddress
self.remoteaddress = sshaddress
remotecmd = '%s -u -c "exec input()"' % (remotepython,)
cmdline = [sshaddress, remotecmd]
# XXX Unix style quoting
@ -179,9 +177,6 @@ class SshGateway(PopenCmdGateway):
cmdline.insert(0, cmd)
super(SshGateway, self).__init__(' '.join(cmdline))
def _getremoteaddress(self):
return self.sshaddress
class ExecGateway(PopenGateway):
def remote_exec_sync_stdcapture(self, lines, callback):
# hack: turn the content of the cell into

View File

@ -110,7 +110,7 @@ class RSync(object):
# sharing multiple copies of the file's data
data = intern(data)
print '%s <= %s' % (
channel.gateway._getremoteaddress(),
channel.gateway.remoteaddress,
modified_rel_path)
channel.send(data)
del data

View File

@ -62,8 +62,8 @@ class PopenGatewayTestSetup:
def setup_class(cls):
cls.gw = py.execnet.PopenGateway()
## def teardown_class(cls):
## cls.gw.exit()
def teardown_class(cls):
cls.gw.exit()
class BasicRemoteExecution:
def test_correct_setup(self):
@ -455,7 +455,7 @@ class TestSshGateway(BasicRemoteExecution):
cls.gw = py.execnet.SshGateway(option.sshtarget)
def test_sshaddress(self):
assert self.gw.sshaddress == option.sshtarget
assert self.gw.remoteaddress == option.sshtarget
def test_failed_connexion(self):
gw = py.execnet.SshGateway('nowhere.codespeak.net')