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

« back to all changes in this revision

Viewing changes to bin/ivle-enrolallusers

  • Committer: me at id
  • Date: 2009-01-15 03:40:17 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:1154
bin/ivle-{list,mountall}users: Don't use ivle.db.

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
import ivle.db
38
38
import ivle.database
39
39
import ivle.pulldown_subj
40
40
 
55
55
    print >> sys.stderr, "%s must be run as root" % sys.argv[0]
56
56
    sys.exit(1)
57
57
 
58
 
store = ivle.database.get_store(ivle.config.Config())
 
58
store = ivle.database.get_store()
59
59
if options.user is None:
60
60
    users = store.find(ivle.database.User).order_by(ivle.database.User.login)
61
61
else:
70
70
    logging.error("Year must be numeric")
71
71
    sys.exit(1)
72
72
 
73
 
options.year = None if options.year is None else unicode(options.year)
74
 
 
75
73
for user in users:
76
74
    try:
77
75
        # Get all subjects this user is enrolled in, and add them to the DB if
78
76
        # they match one of our local subject codes
79
 
        res = ivle.pulldown_subj.enrol_user(store, user, options.year)
 
77
        res = ivle.pulldown_subj.enrol_user(user.login, options.year)
80
78
        logging.info("Enrolled user %s in %d subject%s." % (user.login, res,
81
79
                        '' if res == 1 else 's'))
82
80
    except Exception, message:
83
81
        logging.warning(str(message))
84
82
        continue
85
83
    
86
 
store.commit()
87
84
logging.info("enrolment completed successfully")