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

« back to all changes in this revision

Viewing changes to bin/ivle-showenrolment

  • Committer: chadnickbok
  • Date: 2009-01-19 22:56:46 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1170
This commit fixes issue #10 and part of issue #9

There are now two options for moving files with their
svn history intact; svn move and svn copy. These
use the svn commands to move the files, allowing students
to move and rename files without their histories being
lost.

This commit also shows the svn status of a dir, if it is
the 'head' of an svn repository.

Show diffs side-by-side

added added

removed removed

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