154
157
# (This will create fresh user dirs and repos because the jails were empty.)
155
158
logging.info("Building sample users' filesystems and repos.")
156
159
subprocess.check_call(["bin/ivle-refreshfilesystem"])
162
dbconfig = config['database']
164
# Populate some of the users' Subversion repos
165
def temp_checkout(svnclient, username):
166
"""Checkout user `username`'s repo to a temporary directory.
167
@return: The temporary workspace directory.
169
# Do the checkout over HTTP, since we then use the user's own credentials
170
repourl = config['urls']['svn_addr'] + '/users/' + username
171
# Ignore warnings about the use of tempnam
172
warnings.simplefilter('ignore')
173
tempdir = os.tempnam()
174
warnings.resetwarnings()
175
svnclient.checkout(repourl, tempdir)
178
logging.info("Populating student repositories")
180
svnclient = ivle.svn.create_auth_svn_client_autopass("studenta")
181
workspace = temp_checkout(svnclient, "studenta")
182
dirname = os.path.join(workspace, "stuff")
183
filename = os.path.join(dirname, "hello.py")
184
if not os.path.isdir(dirname):
186
svnclient.add(dirname, force=True)
187
# XXX Copy files from a sample directory
188
f = open(filename, "w")
190
# Hello IVLE, by Alice Student
191
# CGI program -- Prints CGI headers, then HTML output
193
print "Content-Type: text/html"
195
print "<html><body><p>Hello, world!</p></body></html>"
198
svnclient.add(filename, force=True)
199
svnclient.checkin(workspace, "Added some files")
200
shutil.rmtree(workspace)