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

« back to all changes in this revision

Viewing changes to bin/ivle-enrolallusers

  • Committer: William Grant
  • Date: 2009-01-19 23:29:19 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: grantw@unimelb.edu.au-20090119232919-4a6goyk6u1u1m58c
ivle.pulldown_subj: Use Storm, and kill ivle.db dependency. This means we use
    unicodes everywhere, so the pulldown module API has changed slightly.

ivle.pulldown_subj.dummy_subj: Return unicodes, not strs.

bin/ivle-enrolallusers: Remove ivle.db dependency, give enrol_user a store,
    and actually use the current year if one is not specified.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
import pwd
34
34
import optparse
35
35
import logging
 
36
import datetime
36
37
 
37
 
import ivle.db
38
38
import ivle.database
39
39
import ivle.pulldown_subj
40
40
 
70
70
    logging.error("Year must be numeric")
71
71
    sys.exit(1)
72
72
 
 
73
if options.year is None:
 
74
    options.year = datetime.datetime.now().year
 
75
 
 
76
options.year = unicode(options.year)
 
77
 
73
78
for user in users:
74
79
    try:
75
80
        # Get all subjects this user is enrolled in, and add them to the DB if
76
81
        # they match one of our local subject codes
77
 
        res = ivle.pulldown_subj.enrol_user(user.login, options.year)
 
82
        res = ivle.pulldown_subj.enrol_user(store, user, options.year)
78
83
        logging.info("Enrolled user %s in %d subject%s." % (user.login, res,
79
84
                        '' if res == 1 else 's'))
80
85
    except Exception, message:
81
86
        logging.warning(str(message))
82
87
        continue
83
88
    
 
89
store.commit()
84
90
logging.info("enrolment completed successfully")