def remote_exec(self, source, stdout=None, stderr=None): |
""" return channel object and connect it to a remote |
execution thread where the given 'source' executes |
and has the sister 'channel' object in its global |
namespace. The callback functions 'stdout' and |
'stderr' get called on receival of remote |
stdout/stderr output strings. |
""" |
try: |
source = str(Source(source)) |
except NameError: |
try: |
import py |
source = str(py.code.Source(source)) |
except ImportError: |
pass |
channel = self.newchannel() |
outid = self._newredirectchannelid(stdout) |
errid = self._newredirectchannelid(stderr) |
self._outgoing.put(Message.CHANNEL_OPEN(channel.id, |
(source, outid, errid))) |
return channel |