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

« back to all changes in this revision

Viewing changes to bin/ivle-makeuser

Add an ivle-createdatadirs script, to create the hierarchy under /var/lib/ivle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    print "Must run %s as root." % os.path.basename(sys.argv[0])
36
36
    sys.exit(1)
37
37
 
38
 
from ivle.config import Config
39
38
from ivle.database import get_store, User
40
39
from ivle.pulldown_subj import enrol_user
41
40
 
42
41
# Requireds and optionals will be used to display the usage message
43
42
# AND do argument processing
44
43
# The names here must correspond to the fields in the database.
45
 
requireds = ["login", "fullname"]
 
44
requireds = ["login", "fullname", "rolenm"]
46
45
optionals = [
47
46
    ('p', 'password', "Cleartext password for this user"),
48
47
    ('n', 'nick', "Display name (defaults to <fullname>)"),
81
80
if 'nick' not in user:
82
81
    user['nick'] = user['fullname']
83
82
 
84
 
config = Config()
85
 
store = get_store(config)
 
83
store = get_store()
86
84
 
87
85
try:
88
86
    # Make the user's database entry
89
87
    userobj = User(**user)
90
88
    store.add(userobj)
91
 
    enrol_user(config, store, userobj)
 
89
    enrol_user(store, userobj)
92
90
    store.commit()
93
91
except Exception, message:
94
92
    print "Error: " + str(message)