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

« back to all changes in this revision

Viewing changes to bin/ivle-enrolallusers

  • Committer: William Grant
  • Date: 2009-08-02 08:43:33 UTC
  • mto: (1294.2.118 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090802084333-j733m80q8hkrluaz
req.router -> req.publisher

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
import optparse
35
35
import logging
36
36
 
 
37
import ivle.config
37
38
import ivle.database
38
39
import ivle.pulldown_subj
39
40
 
54
55
    print >> sys.stderr, "%s must be run as root" % sys.argv[0]
55
56
    sys.exit(1)
56
57
 
57
 
store = ivle.database.get_store()
 
58
config = ivle.config.Config()
 
59
store = ivle.database.get_store(config)
 
60
 
58
61
if options.user is None:
59
62
    users = store.find(ivle.database.User).order_by(ivle.database.User.login)
60
63
else:
69
72
    logging.error("Year must be numeric")
70
73
    sys.exit(1)
71
74
 
72
 
options.year = unicode(options.year)
 
75
options.year = None if options.year is None else unicode(options.year)
73
76
 
74
77
for user in users:
75
78
    try:
76
79
        # Get all subjects this user is enrolled in, and add them to the DB if
77
80
        # they match one of our local subject codes
78
 
        res = ivle.pulldown_subj.enrol_user(store, user, options.year)
 
81
        res = ivle.pulldown_subj.enrol_user(config, store, user, options.year)
79
82
        logging.info("Enrolled user %s in %d subject%s." % (user.login, res,
80
83
                        '' if res == 1 else 's'))
81
84
    except Exception, message: