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

« back to all changes in this revision

Viewing changes to bin/ivle-makeuser

  • Committer: William Grant
  • Date: 2009-01-22 04:47:42 UTC
  • mfrom: (1080.1.93 storm)
  • Revision ID: grantw@unimelb.edu.au-20090122044742-sa8gnww0ma2bm2rv
Merge Storm branch. ivle.db is dead. Watch out for the schema change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import os
32
32
import getopt
33
33
 
34
 
import ivle.makeuser
 
34
from ivle.database import get_store, User
 
35
from ivle.pulldown_subj import enrol_user
35
36
 
36
37
# Requireds and optionals will be used to display the usage message
37
38
# AND do argument processing
66
67
# Get the dictionary of fields from opts and args
67
68
user = {}
68
69
for i in range(0, len(requireds)):
69
 
    user[requireds[i]] = args[i]
 
70
    user[requireds[i]] = unicode(args[i])
70
71
for short, long, _ in optionals:
71
72
    try:
72
 
        user[long] = opts['-' + short]
 
73
        user[long] = unicode(opts['-' + short])
73
74
    except KeyError:
74
75
        try:
75
 
            user[long] = opts['--' + long]
 
76
            user[long] = unicode(opts['--' + long])
76
77
        except KeyError:
77
78
            pass
78
79
login = user['login']
79
80
if 'nick' not in user:
80
81
    user['nick'] = user['fullname']
81
82
 
 
83
store = get_store()
 
84
 
82
85
try:
83
86
    # Make the user's database entry
84
 
    ivle.makeuser.make_user_db(**user)
 
87
    userobj = User(**user)
 
88
    store.add(userobj)
 
89
    enrol_user(store, userobj)
 
90
    store.commit()
85
91
except Exception, message:
86
92
    print "Error: " + str(message)
87
93
    sys.exit(1)