Port to Python 3.

All scripts and modules have been ported to Python 3 and appear to
work.  Some changes to the lighttpd configuration were needed.
This commit is contained in:
John "Elwin" Edwards 2013-12-31 13:36:19 -05:00
parent 914f367657
commit aef04a38e1
10 changed files with 58 additions and 71 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
import cgi
import os
@ -6,6 +6,7 @@ import sys
import time
import calendar
from datetime import datetime
import pytz
import rlgalldb as rlgall
#import cgitb
@ -55,7 +56,7 @@ def input_datetime(outf, dvals=[None, None, None, None, None, None]):
emptf = '<input type="text" size="2" maxlength="2" name="{0}">'
sstr = '<div>Date: <select name="year">\n'
# Default to today
now = datetime.now(rlgall.utc)
now = datetime.now(pytz.utc)
if dvals[0] == None:
dvals[0] = now.year
if dvals[1] == None:
@ -164,7 +165,7 @@ def processtime(fdata, errlist, hlist):
chtime = time.gmtime(utime)
for i in range(6):
hlist[i] = chtime[i]
return datetime.fromtimestamp(utime, rlgall.utc)
return datetime.fromtimestamp(utime, pytz.utc)
# Now try to get a human-readable specification.
lerrors = []
@ -261,7 +262,7 @@ def processtime(fdata, errlist, hlist):
errlist.extend(lerrors)
return None
#return calendar.timegm([year, month, day, hour, minute, second, 0, 0, 0])
return datetime(year, month, day, hour, minute, second, 0, rlgall.utc)
return datetime(year, month, day, hour, minute, second, 0, pytz.utc)
# Begin processing
fdata = cgi.FieldStorage()
@ -307,7 +308,7 @@ if dosearch:
conn.close()
# Now we are ready to print the page.
sys.stdout.write("Content-type: text/html\r\n\r\n")
sys.stdout.write("Content-Type: text/html; charset=utf-8\r\n\r\n")
sys.stdout.write(rlgall.phead.format("Archive"))
sys.stdout.write(rlgall.ptop)

View file

@ -1,12 +1,16 @@
#!/usr/bin/python
#!/usr/bin/python3
# CGI script creating page of recent games
import sys
import time
import rlgalldb as rlgall
# It is assumed that sys.stdout uses UTF-8 encoding. If this is not the case,
# configure the Web server to set the LC_CTYPE environment variable to a UTF-8
# locale.
# The required header
sys.stdout.write("Content-type: text/html\r\n\r\n")
sys.stdout.write("Content-Type: text/html; charset=utf-8\r\n\r\n")
# The top of the page
sys.stdout.write(rlgall.phead.format("Recent Games"))
sys.stdout.write(rlgall.ptop);

View file

@ -1,8 +1,8 @@
#!/usr/bin/python
#!/usr/bin/python3
import os
import sys
import rlgall
import rlgalldb as rlgall
playerdir = "/var/www/lighttpd/scoring/players/"
linkstr = '<li><a href="./{0}.html">{0}</a></li>\n'
@ -15,7 +15,7 @@ for filename in filelist:
namelist.append(filename.rsplit(".html", 1)[0])
namelist.sort()
sys.stdout.write("Content-type: text/html\r\n\r\n")
sys.stdout.write("Content-Type: text/html; charset=utf-8\r\n\r\n")
sys.stdout.write(rlgall.phead.format("Players"))
sys.stdout.write(rlgall.ptop)
sys.stdout.write(rlgall.navscore.format("Players"))