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

« back to all changes in this revision

Viewing changes to makeuser.py

  • Committer: mattgiuca
  • Date: 2008-02-29 01:18:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:621
Added 2 new apps: home and subjects. Both fairly incomplete, just a basic
    skeleton.
    "home" is the new default app, replacing "files".
    (It has a link to files).

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import os.path
33
33
import pwd
34
34
import getopt
35
 
import random
36
35
# Import modules from the website is tricky since they're in the www
37
36
# directory.
38
37
sys.path.append(os.path.join(os.getcwd(), 'www'))
45
44
requireds = ["login", "fullname", "rolenm"]
46
45
optionals = [
47
46
    ('p', 'password', "Cleartext password for this user"),
48
 
    ('u', 'unixid', "Numeric unix user id"),
49
47
    ('n', 'nick', "Display name (defaults to <fullname>)"),
50
48
    ('e', 'email', "Email address"),
51
49
    ('s', 'studentid', "Student ID")
85
83
if 'nick' not in user:
86
84
    user['nick'] = user['fullname']
87
85
 
88
 
# Resolve the user's username into a UID
89
 
if 'unixid' not in user:
 
86
try:
 
87
    # Resolve the user's username into a UID
 
88
    # Create the user if it does not exist
90
89
    try:
91
90
        (_,_,uid,_,_,_,_) = pwd.getpwnam(login)
92
 
        user['unixid'] = uid
93
91
    except KeyError:
94
 
        pass
95
 
 
96
 
try:
 
92
        if os.system("useradd '%s'" % login) != 0:
 
93
            raise Exception("Failed to add Unix user account")
 
94
        try:
 
95
            (_,_,uid,_,_,_,_) = pwd.getpwnam(login)
 
96
        except KeyError:
 
97
            raise Exception("Failed to add Unix user account")
 
98
    user['unixid'] = uid
97
99
    # Make the user's database entry
98
100
    common.makeuser.make_user_db(**user)
99
101
except Exception, message: