changing the anyserver.py to make it run with py3

actually fixing the issue #1993 i have created.
i tested it successfuly with the command python3 anyserver.py -s tornado -i 127.0.0.1 -p 80 -l
This commit is contained in:
JusticeN
2018-09-05 14:17:33 +02:00
committed by GitHub
parent 33c6dd9656
commit 80582daaa0
+8 -8
View File
@@ -212,16 +212,16 @@ def mongrel2_handler(application, conn, debug=False):
while True: while True:
if debug: if debug:
print "WAITING FOR REQUEST" print("WAITING FOR REQUEST")
# receive a request # receive a request
req = conn.recv() req = conn.recv()
if debug: if debug:
print "REQUEST BODY: %r\n" % req.body print("REQUEST BODY: %r\n" % req.body)
if req.is_disconnect(): if req.is_disconnect():
if debug: if debug:
print "DISCONNECT" print("DISCONNECT")
continue # effectively ignore the disconnect from the client continue # effectively ignore the disconnect from the client
# Set a couple of environment attributes a.k.a. header attributes # Set a couple of environment attributes a.k.a. header attributes
@@ -247,7 +247,7 @@ def mongrel2_handler(application, conn, debug=False):
environ['wsgi.input'] = req.body environ['wsgi.input'] = req.body
if debug: if debug:
print "ENVIRON: %r\n" % environ print("ENVIRON: %r\n" % environ)
# SimpleHandler needs file-like stream objects for # SimpleHandler needs file-like stream objects for
# requests, errors and responses # requests, errors and responses
@@ -282,10 +282,10 @@ def mongrel2_handler(application, conn, debug=False):
# return the response # return the response
if debug: if debug:
print "RESPONSE: %r\n" % response print("RESPONSE: %r\n" % response)
if errors: if errors:
if debug: if debug:
print "ERRORS: %r" % errors print("ERRORS: %r" % errors)
data = "%s\r\n\r\n%s" % (data, errors) data = "%s\r\n\r\n%s" % (data, errors)
conn.reply_http( conn.reply_http(
req, data, code=code, status=status, headers=headers) req, data, code=code, status=status, headers=headers)
@@ -355,8 +355,8 @@ def main():
dest='workers', dest='workers',
help='number of workers number') help='number of workers number')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
print 'starting %s on %s:%s...' % ( print('starting %s on %s:%s...' % (
options.server, options.ip, options.port) options.server, options.ip, options.port))
run(options.server, options.ip, options.port, run(options.server, options.ip, options.port,
logging=options.logging, profiler=options.profiler_dir, logging=options.logging, profiler=options.profiler_dir,
options=options) options=options)