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

« back to all changes in this revision

Viewing changes to lib/common/makeuser.py

  • Committer: drtomc
  • Date: 2008-02-15 04:11:15 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:471
doc/setup/ivle-svn.conf: a non-configured apache config for the svn server
    more so it's on the record than because we want to retain it in the
    long term.
makeuser.py: Add a function to query the database and regenerate the config
    file used to control authorization for the repositories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
import os
36
36
import stat
37
37
import shutil
 
38
import time
38
39
import uuid
39
40
import warnings
40
41
 
49
50
    if res != 0:
50
51
        raise Exception("Cannot create repository for %s" % login)
51
52
 
 
53
def rebuild_svn_config():
 
54
    """Build the complete SVN configuration file.
 
55
    """
 
56
    conn = db.DB()
 
57
    res = conn.query("SELECT login, rolenm FROM login;").dictresult()
 
58
    groups = {}
 
59
    for r in res:
 
60
        role = r['rolenm']
 
61
        if role not in groups:
 
62
            groups[role] = []
 
63
        groups[role].append(r['login'])
 
64
    f = open(conf.svn_conf + ".new", "w")
 
65
    f.write("# IVLE SVN Repositories Configuration\n")
 
66
    f.write("# Auto-generated on %s\n" % time.asctime())
 
67
    f.write("\n")
 
68
    f.write("[groups]\n")
 
69
    for (g,ls) in groups.iteritems():
 
70
        f.write("%s = %s\n" % (g, ",".join(ls)))
 
71
    f.write("\n")
 
72
    for r in res:
 
73
        login = r['login']
 
74
        f.write("[%s:/]\n" % login)
 
75
        f.write("%s = rw\n" % login)
 
76
        f.write("@tutor = r\n")
 
77
        f.write("@lecturer = rw\n")
 
78
        f.write("@admin = rw\n")
 
79
        f.write("\n")
 
80
    f.close()
 
81
    os.rename(conf.svn_conf + ".new", conf.svn_conf)
 
82
 
52
83
def make_svn_config(login):
53
84
    """Add an entry to the apache-svn config file for the given user.
 
85
       Assumes the given user is either a guest or a student.
54
86
    """
55
87
    f = open(conf.svn_conf, "a")
56
88
    f.write("[%s:/]\n" % login)
57
 
    f.write("  %s = rw\n" % login)
58
 
    f.write("  @tutor = r\n")
59
 
    f.write("  @lecturer = rw\n")
60
 
    f.write("  @admin = rw\n")
 
89
    f.write("%s = rw\n" % login)
 
90
    f.write("@tutor = r\n")
 
91
    f.write("@lecturer = rw\n")
 
92
    f.write("@admin = rw\n")
61
93
    f.write("\n")
62
94
    f.close()
63
95