62
def make_svn_repo(path, throw_on_error=True):
63
"""Create a Subversion repository at the given path.
62
def make_svn_repo(login, throw_on_error=True):
63
"""Create a repository for the given user.
65
path = os.path.join(conf.svn_repo_path, login)
66
67
res = os.system("svnadmin create '%s'" % path)
67
68
if res != 0 and throw_on_error:
68
raise Exception("Cannot create repository: %s" % path)
69
raise Exception("Cannot create repository for %s" % login)
69
70
except Exception, exc:
77
78
"""Build the complete SVN configuration file.
80
users = conn.get_users()
81
res = conn.query("SELECT login, rolenm FROM login;").dictresult()
84
85
if role not in groups:
86
groups[role].append(u.login)
87
groups[role].append(r['login'])
87
88
f = open(conf.svn_conf + ".new", "w")
88
89
f.write("# IVLE SVN Repositories Configuration\n")
89
90
f.write("# Auto-generated on %s\n" % time.asctime())
92
93
for (g,ls) in groups.iteritems():
93
94
f.write("%s = %s\n" % (g, ",".join(ls)))
96
f.write("[%s:/]\n" % u.login)
97
f.write("%s = rw\n" % u.login)
98
f.write("[%s:/]\n" % login)
99
f.write("%s = rw\n" % login)
98
100
#f.write("@tutor = r\n")
99
101
#f.write("@lecturer = rw\n")
100
102
#f.write("@admin = rw\n")
103
105
os.rename(conf.svn_conf + ".new", conf.svn_conf)
104
106
chown_to_webserver(conf.svn_conf)
106
def rebuild_svn_group_config():
107
"""Build the complete SVN configuration file for groups
108
def make_svn_config(login, throw_on_error=True):
109
"""Add an entry to the apache-svn config file for the given user.
110
Assumes the given user is either a guest or a student.
110
groups = conn.get_all('project_group',
111
['groupid', 'groupnm', 'projectsetid'])
112
f = open(conf.svn_group_conf + ".new", "w")
113
f.write("# IVLE SVN Group Repositories Configuration\n")
114
f.write("# Auto-generated on %s\n" % time.asctime())
112
f = open(conf.svn_conf, "a")
113
f.write("[%s:/]\n" % login)
114
f.write("%s = rw\n" % login)
115
#f.write("@tutor = r\n")
116
#f.write("@lecturer = rw\n")
117
#f.write("@admin = rw\n")
117
projectsetid = g['projectsetid']
118
offeringinfo = conn.get_offering_info(projectsetid)
119
subj_short_name = offeringinfo['subj_short_name']
120
year = offeringinfo['year']
121
semester = offeringinfo['semester']
122
reponame = "_".join([subj_short_name, year, semester, g['groupnm']])
123
f.write("[%s:/]\n"%reponame)
124
users = conn.get_projectgroup_members(g['groupid'])
126
f.write("%s = rw\n"%u['login'])
129
os.rename(conf.svn_group_conf + ".new", conf.svn_group_conf)
130
chown_to_webserver(conf.svn_group_conf)
120
chown_to_webserver(conf.svn_conf)
132
122
def make_svn_auth(login, throw_on_error=True):
133
123
"""Setup svn authentication for the given user.
237
227
shutil.rmtree(userdir)
238
228
os.makedirs(homedir)
239
229
shutil.move(homebackup, homedir)
240
# Change the ownership of all the files to the right unixid
241
logging.debug("chown %s's home directory files to uid %d"
243
os.chown(userhomedir, uid, uid)
244
for root, dirs, files in os.walk(userhomedir):
245
for fsobj in dirs + files:
246
os.chown(os.path.join(root, fsobj), uid, uid)
248
231
# No user jail exists
249
232
# Set up the user's home directory