[svn r56722] porting the windows-execnet 56717 and 56718 fixes to other active branches

--HG--
branch : trunk
This commit is contained in:
hpk 2008-07-22 21:17:17 +02:00
parent e101bad658
commit c7da98d7a7
2 changed files with 9 additions and 5 deletions

View File

@ -58,7 +58,11 @@ import sys
class Popen2IO:
server_stmt = """
import sys, StringIO
import os, sys, StringIO
if sys.platform == "win32":
import msvcrt
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
io = Popen2IO(sys.stdout, sys.stdin)
sys.stdout = sys.stderr = StringIO.StringIO()
#try:
@ -70,10 +74,6 @@ sys.stdout = sys.stderr = StringIO.StringIO()
error = (IOError, OSError, EOFError)
def __init__(self, infile, outfile):
if sys.platform == 'win32':
import msvcrt
msvcrt.setmode(infile.fileno(), os.O_BINARY)
msvcrt.setmode(outfile.fileno(), os.O_BINARY)
self.outfile, self.infile = infile, outfile
self.readable = self.writeable = True
self.lock = thread.allocate_lock()

View File

@ -51,6 +51,10 @@ class InstallableGateway(gateway.Gateway):
class PopenCmdGateway(InstallableGateway):
def __init__(self, cmd):
infile, outfile = os.popen2(cmd)
if sys.platform == 'win32':
import msvcrt
msvcrt.setmode(infile.fileno(), os.O_BINARY)
msvcrt.setmode(outfile.fileno(), os.O_BINARY)
io = inputoutput.Popen2IO(infile, outfile)
super(PopenCmdGateway, self).__init__(io=io)