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

« back to all changes in this revision

Viewing changes to bin/ivle-fetchsubmissions

Merge from object-publishing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
PYTHON26 = map(int, sys.version[:3].split('.')) >= [2, 6]
50
50
 
51
51
def fetch_submission(submission, target, svnclient, config, zip=False,
52
 
    txt=False):
 
52
    txt=False, verbose=False):
53
53
    """Fetch a submission from a user's repository, and dump it in a given
54
54
    directory.
55
55
    @param submission: Submission object, detailing the submission.
60
60
    @param zip: If True, zips up the submission.
61
61
    @param txt: If True, writes an extra text file with metadata about the
62
62
        submission.
 
63
    @param verbose: If True, writes the name of each submission to stdout.
63
64
    """
64
65
    # submission_name is the name of the user or group who owns the repo
65
66
    submission_name = submission.assessed.principal.short_name
93
94
        else:
94
95
            os.remove(target_final)
95
96
 
 
97
    if verbose:
 
98
        print "Exported submission by: %s (%s)" % (
 
99
            submission.assessed.principal.short_name,
 
100
            submission.assessed.principal.display_name)
 
101
 
96
102
def get_repo_url(submission, config):
97
103
    """Gets a local (file:) URL to the repository for a given submission.
98
104
    This will consult submission.path to find the path within the repository
226
232
        action="store_true", dest="zip",
227
233
        help="Store each submission in a Zip file.",
228
234
        default=False)
 
235
    parser.add_option("-v", "--verbose",
 
236
        action="store_true", dest="verbose",
 
237
        help="Print out the name of each submission as it is extracted.",
 
238
        default=False)
229
239
    parser.add_option("--no-txt",
230
240
        action="store_false", dest="txt",
231
241
        help="Disable writing a text file with data about each submission.",
305
315
    for submission in project.latest_submissions:
306
316
        try:
307
317
            fetch_submission(submission, target_dir, svnclient, config,
308
 
                             zip=options.zip, txt=options.txt)
 
318
                             zip=options.zip, txt=options.txt,
 
319
                             verbose=options.verbose)
309
320
        except Exception, e:
310
321
            # Catch all exceptions (to ensure if one student has a problem, it
311
322
            # is reported, and we can continue)