31
30
if len(sys.argv) != 2:
32
31
print >> sys.stderr, "usage: %s <login>" % os.path.basename(sys.argv[0])
35
store = ivle.database.get_store(ivle.config.Config())
36
user = ivle.database.User.get_by_login(store, sys.argv[1])
39
print>>sys.stderr, "%s: user does not exist"%os.path.basename(sys.argv[0])
36
user = db.get_user(sys.argv[1])
37
except ivle.db.DBException:
38
print >> sys.stderr, "cannot retrieve user - probably doesn't exist"
40
enrols = db.get_enrolment(sys.argv[1])
42
if user.enrolments.count() > 0:
43
print 'IVLE enrolment for %s (%s):' % (user.login, user.fullname)
44
print ' Code Name Year Semester Role'
45
print '-------- ---------- ---- -------- --------'
46
for e in user.enrolments:
47
print '%8s %10s %4s %8s %8s' % (
48
e.offering.subject.code, e.offering.subject.short_name,
49
e.offering.semester.year, e.offering.semester.semester,
44
print 'Showing enrolment for %s (%s):' % (sys.argv[1], user.fullname)
45
print ' Code Name Semester Year'
46
print '-------- ---------- -------- ----'
48
print '%(subj_code)8s %(subj_short_name)10s %(semester)8s %(year)4s' % enrol
53
print '%s (%s) is not enrolled in any IVLE offerings' % (
54
user.login, user.fullname)
50
print '%s (%s) is not enrolled in any offerings' % (sys.argv[1], user.fullname)