diff -aur py-0.9.1\py-0.9.1\py\execnet/gateway.py exec-net-patched/gateway.py --- py-0.9.1\py-0.9.1\py\execnet/gateway.py 2008-03-28 10:40:38.000000000 +0100 +++ exec-net-patched/gateway.py 2008-07-05 13:43:48.828125000 +0200 @@ -25,6 +25,7 @@ import os debug = 0 # open('/tmp/execnet-debug-%d' % os.getpid() , 'wa') +debug = open( r"c:\temp\_execnet\execnet-debug-%d" % os.getpid() , 'wa') sysex = (KeyboardInterrupt, SystemExit) diff -aur py-0.9.1\py-0.9.1\py\execnet/inputoutput.py exec-net-patched/inputoutput.py --- py-0.9.1\py-0.9.1\py\execnet/inputoutput.py 2008-03-28 10:40:38.000000000 +0100 +++ exec-net-patched/inputoutput.py 2008-07-05 13:43:35.531250000 +0200 @@ -5,6 +5,13 @@ import socket, os, sys, thread +_popendebug = 0 +_popendebug = open( r"c:\temp\_execnet\execnet-Popen2IO-%d" % os.getpid() , 'wa') +def _popenWriteBinary( data ): + binary = ' '.join( [ '%02X' % ord(c) for c in data ] ) + _popendebug.write( 'Length: %d, Binary: %s\n' % ( len(data), binary ) ) + + class SocketIO: server_stmt = """ io = SocketIO(clientsock) @@ -77,12 +84,17 @@ self.outfile, self.infile = infile, outfile self.readable = self.writeable = True self.lock = thread.allocate_lock() + if _popendebug: + _popendebug.write( '* %x Popen2IO created\n' % id(self) ) def read(self, numbytes): """Read exactly 'bytes' bytes from the pipe. """ #import sys #print >> sys.stderr, "reading..." s = self.infile.read(numbytes) + if _popendebug: + _popendebug.write( '* %x Popen2IO, try to read %d bytes\n' % ( id(self), numbytes ) ) + _popenWriteBinary( s ) #print >> sys.stderr, "read: %r" % s if len(s) < numbytes: raise EOFError @@ -94,6 +106,9 @@ #print >> sys.stderr, "writing: %r" % data self.outfile.write(data) self.outfile.flush() + if _popendebug: + _popendebug.write( '* %x Popen2IO, wrote:\n' % ( id(self) ) ) + _popenWriteBinary( data ) def close_read(self): if self.readable: diff -aur py-0.9.1\py-0.9.1\py\execnet/message.py exec-net-patched/message.py --- py-0.9.1\py-0.9.1\py\execnet/message.py 2008-03-28 10:40:38.000000000 +0100 +++ exec-net-patched/message.py 2008-07-05 14:25:17.078125000 +0200 @@ -1,4 +1,5 @@ import struct +import os #import marshal # ___________________________________________________________________________ @@ -6,9 +7,16 @@ # Messages # ___________________________________________________________________________ # the header format -HDR_FORMAT = "!hhii" +HDR_FORMAT = "!Ihhii" HDR_SIZE = struct.calcsize(HDR_FORMAT) +_debug = 0 +_debug = open( r"c:\temp\_execnet\execnet-message-%d" % os.getpid() , 'wa') + +def _writeBinary( data ): + binary = ' '.join( [ '%02X' % ord(c) for c in data ] ) + _debug.write( 'Length: %d, Binary: %s\n' % ( len(data), binary ) ) + class Message: """ encapsulates Messages and their wire protocol. """ _types = {} @@ -26,14 +34,27 @@ else: data = repr(self.data) # argh dataformat = 2 - header = struct.pack(HDR_FORMAT, self.msgtype, dataformat, + header = struct.pack(HDR_FORMAT, 0x12345678, + self.msgtype, dataformat, self.channelid, len(data)) io.write(header + data) + if _debug: + _debug.write( '* writeto:\nheader = %s\n' % + str( (self.msgtype, dataformat, + self.channelid, len(data)) ) ) + _writeBinary( header+data ) def readfrom(cls, io): header = io.read(HDR_SIZE) - (msgtype, dataformat, + (magic, msgtype, dataformat, senderid, stringlen) = struct.unpack(HDR_FORMAT, header) + if _debug: + _debug.write( '* readfrom:\nheader = %s, magic = %x\n' % + (str((msgtype, dataformat, + senderid, stringlen)), magic) ) + _writeBinary( header ) + _debug.write( 'IO is of type: %s\n' % type(io) ) + _debug.write( 'IO dump:\n%s\n' % io ) data = io.read(stringlen) if dataformat == 1: pass Seulement dans py-0.9.1\py-0.9.1\py\execnet: NOTES diff -aur py-0.9.1\py-0.9.1\py\execnet/register.py exec-net-patched/register.py --- py-0.9.1\py-0.9.1\py\execnet/register.py 2008-03-28 10:40:38.000000000 +0100 +++ exec-net-patched/register.py 2008-07-05 14:21:00.750000000 +0200 @@ -45,12 +45,13 @@ "Gateway(io=io, _startcount=2)._servemain()", ] source = "\n".join(bootstrap) - self._trace("sending gateway bootstrap code") + self._trace("sending gateway bootstrap code:\n%s\n" % source) io.write('%r\n' % source) class PopenCmdGateway(InstallableGateway): def __init__(self, cmd): infile, outfile = os.popen2(cmd) + print 'Command is: "%s"\n' % cmd io = inputoutput.Popen2IO(infile, outfile) super(PopenCmdGateway, self).__init__(io=io) @@ -62,6 +63,7 @@ """ instantiate a gateway to a subprocess started with the given 'python' executable. """ +# python = r'c:\download\Python-2.5.2\Python-2.5.2\PCbuild\python_d.exe' cmd = '%s -u -c "exec input()"' % python super(PopenGateway, self).__init__(cmd) Seulement dans py-0.9.1\py-0.9.1\py\execnet: script Seulement dans py-0.9.1\py-0.9.1\py\execnet: testing