62
def make_svn_repo(login, throw_on_error=True):
63
"""Create a repository for the given user.
62
def make_svn_repo(path, throw_on_error=True):
63
"""Create a Subversion repository at the given path.
65
path = os.path.join(conf.svn_repo_path, login)
67
66
res = os.system("svnadmin create '%s'" % path)
68
67
if res != 0 and throw_on_error:
69
raise Exception("Cannot create repository for %s" % login)
68
raise Exception("Cannot create repository: %s" % path)
70
69
except Exception, exc:
78
77
"""Build the complete SVN configuration file.
81
res = conn.query("SELECT login, rolenm FROM login;").dictresult()
80
users = conn.get_users()
85
84
if role not in groups:
87
groups[role].append(r['login'])
86
groups[role].append(u.login)
88
87
f = open(conf.svn_conf + ".new", "w")
89
88
f.write("# IVLE SVN Repositories Configuration\n")
90
89
f.write("# Auto-generated on %s\n" % time.asctime())
93
92
for (g,ls) in groups.iteritems():
94
93
f.write("%s = %s\n" % (g, ",".join(ls)))
98
f.write("[%s:/]\n" % login)
99
f.write("%s = rw\n" % login)
96
f.write("[%s:/]\n" % u.login)
97
f.write("%s = rw\n" % u.login)
100
98
#f.write("@tutor = r\n")
101
99
#f.write("@lecturer = rw\n")
102
100
#f.write("@admin = rw\n")
105
103
os.rename(conf.svn_conf + ".new", conf.svn_conf)
106
104
chown_to_webserver(conf.svn_conf)
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.
106
def rebuild_svn_group_config():
107
"""Build the complete SVN configuration file for groups
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")
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())
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'])
120
chown_to_webserver(conf.svn_conf)
129
os.rename(conf.svn_group_conf + ".new", conf.svn_group_conf)
130
chown_to_webserver(conf.svn_group_conf)
122
132
def make_svn_auth(login, throw_on_error=True):
123
133
"""Setup svn authentication for the given user.