view py/ @ 36:09ef92dc4439

Remove the static high score page. Don't create it, change all links, and redirect any requests.
author John "Elwin" Edwards
date Fri, 03 Jan 2014 13:02:29 -0500
parents 25843238434a
line wrap: on
line source


import os
import psycopg2
import rlgall

# Contains a dir for everyone who registered
everydir = "/var/dgl/dgldir/ttyrec/"
# Contains a page for everyone we know about
#knowndir = rlgall.dbdir + "players/"

# Contact the database
conn = psycopg2.connect("dbname=rlg")
cur = conn.cursor()

# newnames is the list of newly registered players who are not yet in the
# database.  updatenames is the set of players whose pages need updating.
cur.execute("SELECT pname FROM players;")
playersInDB = [ row[0] for row in cur.fetchall() ]
playersAll = os.listdir(everydir)
newnames = [ name for name in playersAll if name not in playersInDB ]
updatenames = set(newnames)

# Add the new names to the database
for newplayer in newnames:
  cur.execute("INSERT INTO players VALUES (%s);", [newplayer])

# Update the database for each game.
for game in rlgall.gamelist:

# All the databases have been updated.  Now make the pages.

# The high page has been replaced with a CGI script.

for name in updatenames: