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"])
111
111
logging.info("Dropping database \"%s\"." % dbconfig["name"])
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"])
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"])
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"])
163
163
config = Config()
164
164
dbconfig = config['database']
180
180
logging.info("Populating student repositories")
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):
188
svnclient.add(dirname, force=True)
189
# XXX Copy files from a sample directory
190
f = open(filename, "w")
192
# Hello IVLE, by Alice Student
193
# CGI program -- Prints CGI headers, then HTML output
195
print "Content-Type: text/html"
197
print "<html><body><p>Hello, world!</p></body></html>"
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.
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",
190
if errmsg is not None:
191
logging.error(errmsg)
194
# Load the known SVN dump files
195
svnload("studenta.dump", "users/studenta")
196
svnload("group1.dump", "groups/ivle-102_2009_2_group1")