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

« back to all changes in this revision

Viewing changes to bin/ivle-loadsampledata

  • Committer: Matt Giuca
  • Date: 2010-02-04 03:08:35 UTC
  • Revision ID: matt.giuca@gmail.com-20100204030835-epwx6qs5ippwopl5
Tags: 1.0beta1
Added subversion dumps as part of sample data. ivle-loadsampledata loads these dumps, so the sample data now comes with sample files (requiring a checkout).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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")