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

« back to all changes in this revision

Viewing changes to bin/ivle-loadsampledata

  • Committer: Matt Giuca
  • Date: 2010-07-27 06:53:03 UTC
  • Revision ID: matt.giuca@gmail.com-20100727065303-gs7fn3gc3ccaqfux
Changed database schema 'semester' table. 'year' and 'semester' fields now allow any length, not just 4 or 1 respectively. (LP: #610330).

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
 
106
106
        # Unmount all the jails
107
107
        logging.info("Unmounting all users.")
108
 
        subprocess.check_call(["bin/ivle-mountallusers", "-u"])
 
108
        subprocess.check_call(["ivle-mountallusers", "-u"])
109
109
 
110
110
        # Drop database
111
111
        logging.info("Dropping database \"%s\"." % dbconfig["name"])
138
138
 
139
139
# Build or rebuild all of the users' filesystems and subversion repos
140
140
logging.info("Creating data directories.")
141
 
subprocess.check_call(["bin/ivle-createdatadirs"])
 
141
subprocess.check_call(["ivle-createdatadirs"])
142
142
 
143
143
# Move all of the users' filesystems and subversion repos out of the way
144
144
# (This will clean out the user dirs because there are no users in the DB.)
145
145
logging.info("Moving existing user filesystems and repos out of the way.")
146
 
subprocess.check_call(["bin/ivle-refreshfilesystem"])
 
146
subprocess.check_call(["ivle-refreshfilesystem"])
147
147
 
148
148
# Populate with sample data
149
149
logging.info("Populating database with sample data.")
158
158
# Build all of the users' filesystems and subversion repos
159
159
# (This will create fresh user dirs and repos because the jails were empty.)
160
160
logging.info("Building sample users' filesystems and repos.")
161
 
subprocess.check_call(["bin/ivle-refreshfilesystem"])
 
161
subprocess.check_call(["ivle-refreshfilesystem"])
162
162
 
163
163
config = Config()
164
164
dbconfig = config['database']
178
178
    return tempdir
179
179
 
180
180
logging.info("Populating student repositories")
181
 
 
182
 
svnclient = ivle.svn.create_auth_svn_client_autopass("studenta")
183
 
workspace = temp_checkout(svnclient, "studenta")
184
 
dirname = os.path.join(workspace, "stuff")
185
 
filename = os.path.join(dirname, "hello.py")
186
 
if not os.path.isdir(dirname):
187
 
    os.makedirs(dirname)
188
 
svnclient.add(dirname, force=True)
189
 
# XXX Copy files from a sample directory
190
 
f = open(filename, "w")
191
 
f.write("""\
192
 
# Hello IVLE, by Alice Student
193
 
# CGI program -- Prints CGI headers, then HTML output
194
 
 
195
 
print "Content-Type: text/html"
196
 
print
197
 
print "<html><body><p>Hello, world!</p></body></html>"
198
 
""")
199
 
f.close()
200
 
svnclient.add(filename, force=True)
201
 
svnclient.checkin(workspace, "Added some files")
202
 
shutil.rmtree(workspace)
 
181
def svnload(dumpfile, repo):
 
182
    """Run svnadmin load.
 
183
    @param dumpfile: Dump file to load from, relative to examples/userrepos.
 
184
    @param repo: Repo to write to, relative to /var/lib/ivle/svn/repositories.
 
185
    """
 
186
    f = open(os.path.join("examples/userrepos", dumpfile), "rb")
 
187
    repo = os.path.join(config['paths']['svn']['repo_path'], repo)
 
188
    errmsg = runprog_stderr(["sudo", "-u", "www-data", "svnadmin", "load",
 
189
                             repo], stdin=f)
 
190
    if errmsg is not None:
 
191
        logging.error(errmsg)
 
192
    f.close()
 
193
 
 
194
# Load the known SVN dump files
 
195
svnload("studenta.dump", "users/studenta")
 
196
svnload("group1.dump", "groups/ivle-102_2009_2_group1")