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

« back to all changes in this revision

Viewing changes to bin/ivle-enrolallusers

  • Committer: Nick Chadwick
  • Date: 2009-03-03 01:48:48 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090303014848-dyurvmtmbneohd7f
Modified the setup script to include '.txt' files.

This allows the automatic inclusion of definitions.txt from the rst
code, as it is needed by all worksheets.

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