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

« back to all changes in this revision

Viewing changes to bin/ivle-makeuser

  • Committer: matt.giuca
  • Date: 2009-02-02 22:27:12 UTC
  • Revision ID: svn-v4:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1191
tutorial: Fixed use of wrong variable names (broke during refactor).

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)