mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
[python3] adjust code to Python3 in test scripts. Refs #38
I don't know how to fix big_file.cgi If you know how to get equivalent of this script in Python3, tell me.
This commit is contained in:
parent
df905c7481
commit
a27e9b168c
@ -16,7 +16,7 @@ AC_CONFIG_AUX_DIR(config)
|
|||||||
AC_CONFIG_MACRO_DIR([config/m4])
|
AC_CONFIG_MACRO_DIR([config/m4])
|
||||||
|
|
||||||
PACKAGE=elinks
|
PACKAGE=elinks
|
||||||
VERSION=0.13.0
|
VERSION=0.14.GIT
|
||||||
AC_SUBST(PACKAGE)
|
AC_SUBST(PACKAGE)
|
||||||
AC_SUBST(VERSION)
|
AC_SUBST(VERSION)
|
||||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
|
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Package version])
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import bz2, os, time
|
import bz2, os, time
|
||||||
|
|
||||||
data1 = '<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
data1 = b'<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
||||||
cd1 = bz2.compress(data1)
|
cd1 = bz2.compress(data1)
|
||||||
|
|
||||||
length = len(cd1)
|
length = len(cd1)
|
||||||
next_chunk = hex(length - 10)[2:]
|
next_chunk = hex(length - 10)[2:]
|
||||||
|
|
||||||
os.write(1, "Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: bzip2\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
os.write(1, b"Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: bzip2\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
||||||
os.write(1, "\r\na\r\n")
|
os.write(1, b"\r\na\r\n")
|
||||||
os.write(1, cd1[:10])
|
os.write(1, cd1[:10])
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.write(1, "\r\n%s\r\n" % next_chunk)
|
os.write(1, b"\r\n")
|
||||||
|
os.write(1, bytes(next_chunk, 'iso8859-1'))
|
||||||
|
os.write(1, b"\r\n")
|
||||||
os.write(1, cd1[10:])
|
os.write(1, cd1[10:])
|
||||||
os.write(1, "\r\n0\r\n")
|
os.write(1, b"\r\n0\r\n")
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import os, time, zlib
|
import os, time, zlib
|
||||||
|
|
||||||
data1 = '<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
data1 = b'<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
||||||
cd1 = zlib.compress(data1)
|
cd1 = zlib.compress(data1)
|
||||||
|
|
||||||
length = len(cd1)
|
length = len(cd1)
|
||||||
next_chunk = hex(length - 10)[2:]
|
next_chunk = hex(length - 10)[2:]
|
||||||
|
|
||||||
os.write(1, "Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: deflate\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
os.write(1, b"Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: deflate\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
||||||
os.write(1, "\r\na\r\n")
|
os.write(1, b"\r\na\r\n")
|
||||||
os.write(1, cd1[:10])
|
os.write(1, cd1[:10])
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.write(1, "\r\n%s\r\n" % next_chunk)
|
os.write(1, b"\r\n")
|
||||||
|
os.write(1, bytes(next_chunk, 'iso8859-1'))
|
||||||
|
os.write(1, b"\r\n")
|
||||||
os.write(1, cd1[10:])
|
os.write(1, cd1[10:])
|
||||||
os.write(1, "\r\n0\r\n")
|
os.write(1, b"\r\n0\r\n")
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import gzip, os, time, StringIO
|
import gzip, os, time, six
|
||||||
|
|
||||||
output = StringIO.StringIO()
|
output = six.BytesIO()
|
||||||
|
|
||||||
data1 = '<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
data1 = b'<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
||||||
|
|
||||||
f1 = gzip.GzipFile("/tmp/1.gz", mode = "wb", fileobj=output)
|
f1 = gzip.GzipFile("/tmp/1.gz", mode = "wb", fileobj=output)
|
||||||
f1.write(data1)
|
f1.write(data1)
|
||||||
@ -15,10 +15,12 @@ output.close()
|
|||||||
length = len(cd1)
|
length = len(cd1)
|
||||||
next_chunk = hex(length - 10)[2:]
|
next_chunk = hex(length - 10)[2:]
|
||||||
|
|
||||||
os.write(1, "Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: gzip\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
os.write(1, b"Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: gzip\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
||||||
os.write(1, "\r\na\r\n")
|
os.write(1, b"\r\na\r\n")
|
||||||
os.write(1, cd1[:10])
|
os.write(1, cd1[:10])
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.write(1, "\r\n%s\r\n" % next_chunk)
|
os.write(1, b"\r\n")
|
||||||
|
os.write(1, bytes(next_chunk, 'iso8859-1'))
|
||||||
|
os.write(1, b"\r\n")
|
||||||
os.write(1, cd1[10:])
|
os.write(1, cd1[10:])
|
||||||
os.write(1, "\r\n0\r\n")
|
os.write(1, b"\r\n0\r\n")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import os, time
|
import os, time
|
||||||
from zlib import *
|
from zlib import *
|
||||||
|
|
||||||
@ -6,17 +6,19 @@ from zlib import *
|
|||||||
# requires a ZLIB header. However, Microsoft-IIS/6.0 sends a raw
|
# requires a ZLIB header. However, Microsoft-IIS/6.0 sends a raw
|
||||||
# DEFLATE stream instead. This CGI tests how ELinks handles that.
|
# DEFLATE stream instead. This CGI tests how ELinks handles that.
|
||||||
|
|
||||||
data1 = '<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
data1 = b'<html><body>Two lines should be visible.<br/>The second line.</body></html>'
|
||||||
ob = compressobj(Z_DEFAULT_COMPRESSION, DEFLATED, -MAX_WBITS)
|
ob = compressobj(Z_DEFAULT_COMPRESSION, DEFLATED, -MAX_WBITS)
|
||||||
cd1 = ob.compress(data1)
|
cd1 = ob.compress(data1)
|
||||||
cd1 += ob.flush()
|
cd1 += ob.flush()
|
||||||
length = len(cd1)
|
length = len(cd1)
|
||||||
next_chunk = hex(length - 10)[2:]
|
next_chunk = hex(length - 10)[2:]
|
||||||
|
|
||||||
os.write(1, "Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: deflate\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
os.write(1, b"Date: Sun, 20 Jan 2008 15:24:00 GMT\r\nServer: ddd\r\nTransfer-Encoding: chunked\r\nContent-Encoding: deflate\r\nConnection: close\r\nContent-Type: text/html; charset=ISO-8859-1\r\n")
|
||||||
os.write(1, "\r\na\r\n")
|
os.write(1, b"\r\na\r\n")
|
||||||
os.write(1, cd1[:10])
|
os.write(1, cd1[:10])
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
os.write(1, "\r\n%s\r\n" % next_chunk)
|
os.write(1, b"\r\n")
|
||||||
|
os.write(1, bytes(next_chunk, 'iso8859-1'))
|
||||||
|
os.write(1, b"\r\n")
|
||||||
os.write(1, cd1[10:])
|
os.write(1, cd1[10:])
|
||||||
os.write(1, "\r\n0\r\n")
|
os.write(1, b"\r\n0\r\n")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from BaseHTTPServer import *
|
from http.server import *
|
||||||
import tempfile
|
import tempfile
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class forwarder(BaseHTTPRequestHandler):
|
|||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-Type", "text/plain")
|
self.send_header("Content-Type", "text/plain")
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write("Dummy response")
|
self.wfile.write(b"Dummy response")
|
||||||
|
|
||||||
def runtest(r, *args):
|
def runtest(r, *args):
|
||||||
form = get_form(*args)
|
form = get_form(*args)
|
||||||
@ -109,7 +109,7 @@ if pid:
|
|||||||
paths.append(("%d %d %d " % (c, e, f)) + runtest(r, c, e, f))
|
paths.append(("%d %d %d " % (c, e, f)) + runtest(r, c, e, f))
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
print path,
|
print(path, end=' ')
|
||||||
|
|
||||||
os.kill(pid, signal.SIGTERM)
|
os.kill(pid, signal.SIGTERM)
|
||||||
os.waitpid(pid, 0)
|
os.waitpid(pid, 0)
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
import gzip, string, cStringIO, os, time, BaseHTTPServer
|
import gzip, string, six, os, time, http.server
|
||||||
|
|
||||||
data = [str(i) for i in xrange(34000)]
|
data = [str(i) for i in range(34000)]
|
||||||
text = "\n".join(data)
|
text = "\n".join(data)
|
||||||
s = cStringIO.StringIO()
|
s = six.BytesIO()
|
||||||
gz = gzip.GzipFile("1.gz", "wb", 9, s)
|
gz = gzip.GzipFile("1.gz", "wb", 9, s)
|
||||||
gz.write(text)
|
gz.write(bytes(text, 'iso8859-1'))
|
||||||
gz.close()
|
gz.close()
|
||||||
comp = s.getvalue()
|
comp = s.getvalue()
|
||||||
s.close()
|
s.close()
|
||||||
pocz = comp[:65536]
|
pocz = comp[:65536]
|
||||||
reszta = comp[65536:]
|
reszta = comp[65536:]
|
||||||
|
|
||||||
class obsluga(BaseHTTPServer.BaseHTTPRequestHandler):
|
class obsluga(http.server.BaseHTTPRequestHandler):
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-Type", "text/plain")
|
self.send_header("Content-Type", "text/plain")
|
||||||
@ -25,7 +25,7 @@ class obsluga(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
def run(port=8900):
|
def run(port=8900):
|
||||||
server_address = ('127.0.0.1', port)
|
server_address = ('127.0.0.1', port)
|
||||||
httpd = BaseHTTPServer.HTTPServer(server_address, obsluga)
|
httpd = http.server.HTTPServer(server_address, obsluga)
|
||||||
httpd.handle_request()
|
httpd.handle_request()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user