Mercurial > hg > rlgallery-misc
view py/recorder.py @ 55:e421ea2519ec
dgamelaunch: define user/group by name instead of UID/GID.
The user and group might not be created with the UID and GID expected,
so it is better to use names. They can be changed to numeric values
after installation.
author | John "Elwin" Edwards |
---|---|
date | Sun, 11 May 2014 08:32:31 -0700 |
parents | 09ef92dc4439 |
children |
line wrap: on
line source
#!/usr/bin/python3 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]) conn.commit() cur.close() conn.close() # Update the database for each game. for game in rlgall.gamelist: updatenames.update(game.loadnew()) # All the databases have been updated. Now make the pages. # The high page has been replaced with a CGI script. #rlgall.highpage() for name in updatenames: rlgall.playerpage(name) exit()