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

« back to all changes in this revision

Viewing changes to bin/ivle-enrol

  • Committer: Matt Giuca
  • Date: 2009-04-23 08:21:35 UTC
  • Revision ID: matt.giuca@gmail.com-20090423082135-5lda1g114ocpc73e
Fileservice: Improved the error message "Revision not found" to
    "Revision not found or file not found in revision $n".
    This error appears whenever the file is not in the given revision, even if
    the revision exists in the repository, so the new text should be less
    confusing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import os
26
26
import sys
27
27
 
28
 
from ivle.config import Config
29
28
from ivle.database import get_store, Subject, Semester, Offering, User
30
29
 
31
30
def die(error):
33
32
    sys.exit(1)
34
33
 
35
34
if len(sys.argv) not in (5, 6):
36
 
    print >> sys.stderr, '''usage: %s <login> <subjectcode> <year> <semestercode> [role]
 
35
    print >> sys.stderr, '''usage: %s <login> <subjectcode> <year> <semester> [role]
37
36
 
38
37
'role' should be one of student (the default), tutor or lecturer.
39
38
If an enrolment already exists, it will be reactivated and its role set.''' \
40
39
                         % os.path.basename(sys.argv[0])
41
40
    sys.exit()
42
41
 
43
 
store = get_store(Config())
 
42
store = get_store()
44
43
 
45
44
user = User.get_by_login(store, sys.argv[1])
46
45
if user is None:
49
48
offering = store.find(Offering,
50
49
                    Subject.code == unicode(sys.argv[2]),
51
50
                    Semester.year == unicode(sys.argv[3]),
52
 
                    Semester.code == unicode(sys.argv[4]),
 
51
                    Semester.semester == unicode(sys.argv[4]),
53
52
                    Offering.subject_id == Subject.id,
54
53
                    Offering.semester_id == Semester.id).one()
55
54
if not offering: