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

« back to all changes in this revision

Viewing changes to makeuser.py

  • Committer: mattgiuca
  • Date: 2008-07-15 09:18:02 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:877
pulldown_subj/__init__.py: Added "enrol_user" function which pulls down a user
    and also enrols them in the database.
Added script enrolallusers.py which scriptulously performs automatic
enrolments of all users in the system, similar to remakeallusers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
import sys
31
31
import os
 
32
import os.path
 
33
import pwd
32
34
import getopt
33
 
import common.makeuser
 
35
import random
 
36
# Import modules from the website is tricky since they're in the www
 
37
# directory.
 
38
sys.path.append(os.path.join(os.getcwd(), 'www'))
 
39
import conf
 
40
import common.makeuser, common.db
34
41
 
35
42
# Requireds and optionals will be used to display the usage message
36
43
# AND do argument processing
38
45
requireds = ["login", "fullname", "rolenm"]
39
46
optionals = [
40
47
    ('p', 'password', "Cleartext password for this user"),
 
48
    ('u', 'unixid', "Numeric unix user id"),
41
49
    ('n', 'nick', "Display name (defaults to <fullname>)"),
42
50
    ('e', 'email', "Email address"),
43
51
    ('s', 'studentid', "Student ID")
77
85
if 'nick' not in user:
78
86
    user['nick'] = user['fullname']
79
87
 
 
88
# Resolve the user's username into a UID
 
89
if 'unixid' not in user:
 
90
    try:
 
91
        (_,_,uid,_,_,_,_) = pwd.getpwnam(login)
 
92
        user['unixid'] = uid
 
93
    except KeyError:
 
94
        user['unixid'] = random.randrange(5000,10000)
 
95
 
80
96
try:
81
97
    # Make the user's database entry
82
98
    common.makeuser.make_user_db(**user)