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

« back to all changes in this revision

Viewing changes to makeuser.py

  • Committer: stevenbird
  • Date: 2008-02-15 12:03:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:480
doc/setup/install_proc.txt
* mentioned command to drop database (for cases when the schema was changed)
* updated command line argument info for makeuser.py
* listed roles
* moved apt-get for apache to the top section with other apt-gets

makeuser.py
* changed variable name "dict" to "user" (shouldn't redefine dict!)
* added -x flag to make it possible to set state (e.g. -x enabled)
  (failed attempt to get around problem that accepting TOS doesn't work)

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    ('n', 'nick', "Display name (defaults to <fullname>)"),
48
48
    ('e', 'email', "Email address"),
49
49
    ('s', 'studentid', "Student ID"),
 
50
    ('x', 'state', "Account status (defaults to no_agreement)")
50
51
]
51
52
 
52
53
if len(sys.argv) <= 3:
68
69
opts = dict(opts)
69
70
 
70
71
# Get the dictionary of fields from opts and args
71
 
dict = {}
 
72
user = {}
72
73
for i in range(0, len(requireds)):
73
 
    dict[requireds[i]] = args[i]
 
74
    user[requireds[i]] = args[i]
74
75
for short, long, _ in optionals:
75
76
    try:
76
 
        dict[long] = opts['-' + short]
 
77
        user[long] = opts['-' + short]
77
78
    except KeyError:
78
79
        try:
79
 
            dict[long] = opts['--' + long]
 
80
            user[long] = opts['--' + long]
80
81
        except KeyError:
81
82
            pass
82
 
login = dict['login']
83
 
if 'nick' not in dict:
84
 
    dict['nick'] = dict['fullname']
 
83
login = user['login']
 
84
if 'nick' not in user:
 
85
    user['nick'] = user['fullname']
85
86
 
86
87
try:
87
88
    # Resolve the user's username into a UID
95
96
            (_,_,uid,_,_,_,_) = pwd.getpwnam(login)
96
97
        except KeyError:
97
98
            raise Exception("Failed to add Unix user account")
98
 
    dict['unixid'] = uid
 
99
    user['unixid'] = uid
99
100
    # Make the user's jail
100
101
    common.makeuser.make_jail(login, uid)
101
102
    # Make the user's database entry
102
 
    common.makeuser.make_user_db(**dict)
 
103
    common.makeuser.make_user_db(**user)
103
104
except Exception, message:
104
105
    print "Error: " + str(message)
105
106
    sys.exit(1)
106
107
 
107
 
print "Successfully created user %s (%s)." % (login, dict['fullname'])
 
108
print "Successfully created user %s (%s)." % (login, user['fullname'])