make all syntax compatible with 3.1 and 2.5

--HG--
branch : trunk
This commit is contained in:
Benjamin Peterson
2009-08-29 13:04:48 -05:00
parent 6f4c6d36a4
commit ee1747fcb4
60 changed files with 230 additions and 177 deletions

View File

@@ -9,7 +9,7 @@ import sys, os, socket, select
try:
clientsock
except NameError:
print "client side starting"
print("client side starting")
import sys
host, port = sys.argv[1].split(':')
port = int(port)
@@ -17,7 +17,7 @@ except NameError:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, port))
sock.sendall(repr(myself)+'\n')
print "send boot string"
print("send boot string")
inputlist = [ sock, sys.stdin ]
try:
while 1:
@@ -31,11 +31,11 @@ except NameError:
sys.stdout.flush()
except:
import traceback
print traceback.print_exc()
print(traceback.print_exc())
sys.exit(1)
print "server side starting"
print("server side starting")
# server side
#
from traceback import print_exc
@@ -47,7 +47,7 @@ class promptagent(Thread):
self.clientsock = clientsock
def run(self):
print "Entering thread prompt loop"
print("Entering thread prompt loop")
clientfile = self.clientsock.makefile('w')
filein = self.clientsock.makefile('r')
@@ -58,22 +58,23 @@ class promptagent(Thread):
clientfile.write('%s %s >>> ' % loc)
clientfile.flush()
line = filein.readline()
if len(line)==0: raise EOFError,"nothing"
if len(line)==0: raise EOFError("nothing")
#print >>sys.stderr,"got line: " + line
if line.strip():
oldout, olderr = sys.stdout, sys.stderr
sys.stdout, sys.stderr = clientfile, clientfile
try:
try:
exec compile(line + '\n','<remote pyin>', 'single')
exec(compile(line + '\n','<remote pyin>', 'single'))
except:
print_exc()
finally:
sys.stdout=oldout
sys.stderr=olderr
clientfile.flush()
except EOFError,e:
print >>sys.stderr, "connection close, prompt thread returns"
except EOFError:
e = sys.exc_info()[1]
sys.stderr.write("connection close, prompt thread returns")
break
#print >>sys.stdout, "".join(apply(format_exception,sys.exc_info()))
@@ -81,4 +82,4 @@ class promptagent(Thread):
prompter = promptagent(clientsock)
prompter.start()
print "promptagent - thread started"
print("promptagent - thread started")