moth/tanks/www/results.cgi

56 lines
1.2 KiB
Plaintext
Raw Normal View History

2009-10-06 11:50:21 -06:00
#!/usr/bin/python
import cgitb; cgitb.enable()
import os
2009-10-06 12:47:36 -06:00
import Config
2009-10-06 11:50:21 -06:00
print """Content-Type: text/html\n\n"""
print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n\n"""
head = open('head.html').read() % "Pflanzarr Results"
print head
print "<H1>Results</H1>"
2009-10-06 12:47:36 -06:00
print open('links.html').read()
2009-10-06 11:50:21 -06:00
try:
2009-10-06 12:47:36 -06:00
winner = open(os.path.join(Config.DATA_PATH, 'winner')).read()
2009-10-06 11:50:21 -06:00
except:
winner = "No winner yet."
print "<H3>Last Winner: ", winner, '<H3>'
print "<H2>Results so far:</H2>"
try:
2009-10-06 12:47:36 -06:00
games = os.listdir(os.path.join('results'))
2009-10-06 11:50:21 -06:00
except:
2009-10-06 12:47:36 -06:00
print '<p>The results directory does not exist.'
2009-10-06 11:50:21 -06:00
games = []
if not games:
print "<p>No games have occurred yet."
2009-10-08 09:04:07 -06:00
2009-10-06 11:50:21 -06:00
gameNums = []
for game in games:
try:
2009-10-08 09:04:07 -06:00
gameNums.append( int(game) )
2009-10-06 11:50:21 -06:00
except:
continue
gameNums.sort(reverse=True)
2009-10-08 09:04:07 -06:00
# Don't include games that haven't completed
i = 0
num = str(gameNums[i])
for i in range(len(gameNums)):
path = os.path.join( 'results', str(gameNums[i]), 'results.html') )
if os.path.exists( path ):
break
gameNums = gameNums[i:]
2009-10-06 11:50:21 -06:00
for num in gameNums:
print '<p>%d - ' % num,
2009-10-06 12:47:36 -06:00
print '<a href="results/%d/game.avi">v</a>' % num,
print '<a href="results/%d/results.html">r</a>' % num
2009-10-08 09:04:07 -06:00
print '</body></html>'