Skip to content

Commit 411f1e9

Browse files
committed
Python 3 preparation: write bytes to socket in roundup_server.py.
1 parent a77b9d3 commit 411f1e9

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

roundup/scripts/roundup_server.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
# Roundup modules of use here
6565
from roundup.anypy import http_, urllib_
66-
from roundup.anypy.strings import StringIO
66+
from roundup.anypy.strings import s2b, StringIO
6767
from roundup.cgi import cgitb, client
6868
from roundup.cgi.PageTemplates.PageTemplate import PageTemplate
6969
import roundup.instance
@@ -237,20 +237,20 @@ def run_cgi(self):
237237
if self.DEBUG_MODE:
238238
try:
239239
reload(cgitb)
240-
self.wfile.write(cgitb.breaker())
241-
self.wfile.write(cgitb.html())
240+
self.wfile.write(s2b(cgitb.breaker()))
241+
self.wfile.write(s2b(cgitb.html()))
242242
except:
243243
s = StringIO()
244244
traceback.print_exc(None, s)
245-
self.wfile.write("<pre>")
246-
self.wfile.write(cgi.escape(s.getvalue()))
247-
self.wfile.write("</pre>\n")
245+
self.wfile.write(b"<pre>")
246+
self.wfile.write(s2b(cgi.escape(s.getvalue())))
247+
self.wfile.write(b"</pre>\n")
248248
else:
249249
# user feedback
250-
self.wfile.write(cgitb.breaker())
250+
self.wfile.write(s2b(cgitb.breaker()))
251251
ts = time.ctime()
252-
self.wfile.write('''<p>%s: An error occurred. Please check
253-
the server log for more information.</p>'''%ts)
252+
self.wfile.write(s2b('''<p>%s: An error occurred. Please check
253+
the server log for more information.</p>'''%ts))
254254
# out to the logfile
255255
print('EXCEPTION AT', ts)
256256
traceback.print_exc()
@@ -281,16 +281,16 @@ def index(self):
281281
'true' : 1,
282282
'false' : 0,
283283
}
284-
w(pt.pt_render(extra_context=extra))
284+
w(s2b(pt.pt_render(extra_context=extra)))
285285
else:
286-
w(_('<html><head><title>Roundup trackers index</title></head>\n'
287-
'<body><h1>Roundup trackers index</h1><ol>\n'))
286+
w(s2b(_('<html><head><title>Roundup trackers index</title></head>\n'
287+
'<body><h1>Roundup trackers index</h1><ol>\n')))
288288
keys.sort()
289289
for tracker in keys:
290-
w('<li><a href="%(tracker_url)s/index">%(tracker_name)s</a>\n'%{
290+
w(s2b('<li><a href="%(tracker_url)s/index">%(tracker_name)s</a>\n'%{
291291
'tracker_url': urllib_.quote(tracker),
292-
'tracker_name': cgi.escape(tracker)})
293-
w('</ol></body></html>')
292+
'tracker_name': cgi.escape(tracker)}))
293+
w(b'</ol></body></html>')
294294

295295
def inner_run_cgi(self):
296296
''' This is the inner part of the CGI handling
@@ -359,7 +359,7 @@ def inner_run_cgi(self):
359359
url += '?' + query
360360
self.send_header('Location', url)
361361
self.end_headers()
362-
self.wfile.write('Moved Permanently')
362+
self.wfile.write(b'Moved Permanently')
363363
return
364364

365365
# figure out what the rest of the path is

0 commit comments

Comments
 (0)