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

« back to all changes in this revision

Viewing changes to bin/ivle-fetchsubmissions

  • Committer: William Grant
  • Date: 2009-05-13 02:41:25 UTC
  • mto: This revision was merged to the branch mainline in revision 1247.
  • Revision ID: grantw@unimelb.edu.au-20090513024125-3a3ctt1hezx0y5mo
Link to +projects rather than +groups on /subjects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import optparse
33
33
import zipfile
34
34
import traceback
35
 
import locale
36
35
 
37
36
import pysvn
38
37
 
46
45
 
47
46
from ivle.database import Project, ProjectSet, Offering, Subject
48
47
 
49
 
# Set locale to UTF-8
50
 
locale.setlocale(locale.LC_CTYPE, "en_US.UTF-8")
51
 
 
52
48
# Is Python version 2.6 or higher?
53
49
PYTHON26 = map(int, sys.version[:3].split('.')) >= [2, 6]
54
50
 
55
51
def fetch_submission(submission, target, svnclient, config, zip=False,
56
 
    txt=False, verbose=False):
 
52
    txt=False):
57
53
    """Fetch a submission from a user's repository, and dump it in a given
58
54
    directory.
59
55
    @param submission: Submission object, detailing the submission.
64
60
    @param zip: If True, zips up the submission.
65
61
    @param txt: If True, writes an extra text file with metadata about the
66
62
        submission.
67
 
    @param verbose: If True, writes the name of each submission to stdout.
68
63
    """
69
64
    # submission_name is the name of the user or group who owns the repo
70
65
    submission_name = submission.assessed.principal.short_name
98
93
        else:
99
94
            os.remove(target_final)
100
95
 
101
 
    if verbose:
102
 
        print "Exported submission by: %s (%s)" % (
103
 
            submission.assessed.principal.short_name,
104
 
            submission.assessed.principal.display_name)
105
 
 
106
96
def get_repo_url(submission, config):
107
97
    """Gets a local (file:) URL to the repository for a given submission.
108
98
    This will consult submission.path to find the path within the repository
236
226
        action="store_true", dest="zip",
237
227
        help="Store each submission in a Zip file.",
238
228
        default=False)
239
 
    parser.add_option("-v", "--verbose",
240
 
        action="store_true", dest="verbose",
241
 
        help="Print out the name of each submission as it is extracted.",
242
 
        default=False)
243
229
    parser.add_option("--no-txt",
244
230
        action="store_false", dest="txt",
245
231
        help="Disable writing a text file with data about each submission.",
319
305
    for submission in project.latest_submissions:
320
306
        try:
321
307
            fetch_submission(submission, target_dir, svnclient, config,
322
 
                             zip=options.zip, txt=options.txt,
323
 
                             verbose=options.verbose)
 
308
                             zip=options.zip, txt=options.txt)
324
309
        except Exception, e:
325
310
            # Catch all exceptions (to ensure if one student has a problem, it
326
311
            # is reported, and we can continue)