~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/ivle-loadsampledata

  • Committer: William Grant
  • Date: 2009-12-14 03:43:51 UTC
  • Revision ID: me@williamgrant.id.au-20091214034351-j0gbqkrmp3b1iawz
Don't ask for the 'ivle' user password in loadsampledata; get it from the DB.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import logging
29
29
import readline
30
30
 
 
31
import psycopg2
 
32
 
31
33
from ivle.config import Config
32
34
 
33
35
logging.basicConfig(
120
122
 
121
123
# Populate with database schema
122
124
logging.info("Populating database with schema.")
123
 
file = open("userdb/users.sql")
124
 
proc = subprocess.Popen(["psql", "-h", "localhost", "-W", dbconfig["name"],
125
 
                           dbconfig["username"]], stdin=file)
126
 
if proc.wait() != 0:
127
 
    file.close()
128
 
    sys.exit(1)
129
 
file.close()
 
125
ivleconn = psycopg2.connect(
 
126
    host='localhost', database=dbconfig['name'], user=dbconfig['username'],
 
127
    password=dbconfig['password'])
 
128
ivlecursor = ivleconn.cursor()
 
129
logging.info("Populating database with schema.")
 
130
schemafile = open("userdb/users.sql")
 
131
ivlecursor.execute(schemafile.read())
 
132
schemafile.close()
130
133
 
131
134
# Build or rebuild all of the users' filesystems and subversion repos
132
135
logging.info("Creating data directories.")