2009-10-06 11:50:21 -06:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import cgitb; cgitb.enable()
|
|
|
|
import os
|
2009-10-09 08:47:19 -06:00
|
|
|
from ctf import config
|
2009-10-06 11:50:21 -06:00
|
|
|
|
2009-10-06 12:47:36 -06:00
|
|
|
import Config
|
|
|
|
|
2009-10-09 08:47:19 -06:00
|
|
|
print(config.start_html('Tanks Results',
|
|
|
|
links_title='Tanks',
|
|
|
|
links=[('docs.cgi', 'Docs'),
|
|
|
|
('results.cgi', 'Results'),
|
|
|
|
('submit.html', 'Submit'),
|
|
|
|
('errors.cgi', 'My Errors')]))
|
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)):
|
2009-10-08 11:32:24 -06:00
|
|
|
path = os.path.join( 'results', str(gameNums[i]), 'results.html')
|
2009-10-08 09:04:07 -06:00
|
|
|
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
|
|
|
|
2009-10-09 08:47:19 -06:00
|
|
|
print(config.end_html())
|