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

« back to all changes in this revision

Viewing changes to bin/ivle-loadsampledata

  • Committer: David Coles
  • Date: 2009-12-09 04:47:49 UTC
  • Revision ID: coles.david@gmail.com-20091209044749-e5spfs587z918d99
Fix references in Documentation

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
 
 
33
31
from ivle.config import Config
34
32
 
35
33
logging.basicConfig(
122
120
 
123
121
# Populate with database schema
124
122
logging.info("Populating database with schema.")
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()
 
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()
133
130
 
134
131
# Build or rebuild all of the users' filesystems and subversion repos
135
132
logging.info("Creating data directories.")