~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-20 09:41:48 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:522
Add quite a lot of stuff to get usrmgt happening.

login.py: A little bit of robustifying logic that logs you out if your account
    is still pending when you try to auth. Basically, this forces usrmgt-server
    to have another try.

authenticate.py: A small code rearrangement to produce the right behaviour
    (a generic login/passwd error) when an unknown user logs in (better than
    an internal server error :-) ).

usrmgt-server, makeuser.py: Lots of stuff to setup users. Quite a bit of stuff
    that should be db-driven is hard coded at the moment. (Only a week and a
    half till students will be hitting it, and we can't do everything!)

setup.py: Add an extra bit of svn related config.

users.sql,user.py,db.py: Add the svn_pass column to allow ivle to auth to the
    subversion server.

studpath.py: update a couple of comments to reflect a newer view of the world.

python-console: Add some timeout magic. Actually, I don't think this works,
    but it's well after bedtime, and I've still got to ride home from work.
    The morning will be soon enough.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
import conf
43
43
import db
44
44
 
45
 
def make_svn_repo(login):
 
45
def make_svn_repo(login, throw_on_error=True):
46
46
    """Create a repository for the given user.
47
47
    """
48
48
    path = os.path.join(conf.svn_repo_path, login)
49
 
    res = os.system("svnadmin create '%s'" % path)
50
 
    if res != 0:
51
 
        raise Exception("Cannot create repository for %s" % login)
 
49
    try:
 
50
        res = os.system("svnadmin create '%s'" % path)
 
51
        if res != 0 and throw_on_error:
 
52
            raise Exception("Cannot create repository for %s" % login)
 
53
    except Exception, exc:
 
54
        print repr(exc)
 
55
        if throw_on_error:
 
56
            raise
52
57
 
53
58
def rebuild_svn_config():
54
59
    """Build the complete SVN configuration file.
73
78
        login = r['login']
74
79
        f.write("[%s:/]\n" % login)
75
80
        f.write("%s = rw\n" % login)
76
 
        f.write("@tutor = r\n")
77
 
        f.write("@lecturer = rw\n")
78
 
        f.write("@admin = rw\n")
 
81
        #f.write("@tutor = r\n")
 
82
        #f.write("@lecturer = rw\n")
 
83
        #f.write("@admin = rw\n")
79
84
        f.write("\n")
80
85
    f.close()
81
86
    os.rename(conf.svn_conf + ".new", conf.svn_conf)
82
87
 
83
 
def make_svn_config(login):
 
88
def make_svn_config(login, throw_on_error=True):
84
89
    """Add an entry to the apache-svn config file for the given user.
85
90
       Assumes the given user is either a guest or a student.
86
91
    """
87
92
    f = open(conf.svn_conf, "a")
88
93
    f.write("[%s:/]\n" % login)
89
94
    f.write("%s = rw\n" % login)
90
 
    f.write("@tutor = r\n")
91
 
    f.write("@lecturer = rw\n")
92
 
    f.write("@admin = rw\n")
 
95
    #f.write("@tutor = r\n")
 
96
    #f.write("@lecturer = rw\n")
 
97
    #f.write("@admin = rw\n")
93
98
    f.write("\n")
94
99
    f.close()
95
100
 
96
 
def make_svn_auth(login):
 
101
def make_svn_auth(login, throw_on_error=True):
97
102
    """Setup svn authentication for the given user.
98
103
       FIXME: create local.auth entry
99
104
    """
103
108
    else:
104
109
        create = "c"
105
110
 
106
 
    db.DB().update_user({'svn_pass':passwd})
 
111
    db.DB().update_user(login, svn_pass=passwd)
107
112
 
108
 
    res = os.system("htpasswd -%smb %s %s" % (create,
 
113
    res = os.system("htpasswd -%smb %s %s %s" % (create,
109
114
                                              conf.svn_auth_ivle,
110
115
                                              login, passwd))
111
 
    if res != 0:
 
116
    if res != 0 and throw_on_error:
112
117
        raise Exception("Unable to create ivle-auth for %s" % login)
113
118
 
 
119
    return passwd
 
120
 
114
121
def make_jail(username, uid, force=True):
115
122
    """Creates a new user's jail space, in the jail directory as configured in
116
123
    conf.py.