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

« back to all changes in this revision

Viewing changes to bin/ivle-makeuser

  • Committer: me at id
  • Date: 2009-01-15 05:53:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1161
bin/ivle-showenrolment: Switch to ivle.database.User.enrolments from
    ivle.db.get_enrolment, removing the dependency on ivle.db.

Show diffs side-by-side

added added

removed removed

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