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

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/action.py

  • Committer: William Grant
  • Date: 2009-01-22 04:02:36 UTC
  • mfrom: (1089)
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: grantw@unimelb.edu.au-20090122040236-nm0lby0aymmzk5d7
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
135
135
import pysvn
136
136
 
137
137
from ivle import (util, studpath, zip)
 
138
from ivle.fileservice_lib.exceptions import WillNotOverwrite
138
139
import ivle.conf
139
140
 
 
141
 
140
142
def get_login(_realm, existing_login, _may_save):
141
143
    """Callback function used by pysvn for authentication.
142
144
    realm, existing_login, _may_save: The 3 arguments passed by pysvn to
400
402
 
401
403
    Reads fields: 'path', 'data' (file upload, multiple), 'unpack'
402
404
    """
403
 
 
404
405
    # Important: Data is "None" if the file submitted is empty.
405
406
    path = fields.getfirst('path')
406
407
    data = fields['data']
419
420
    for datum in data:
420
421
        # Each of the uploaded files
421
422
        filepath = os.path.join(path, datum.filename)
 
423
        (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)
 
424
        if os.path.isdir(filepath_local):
 
425
            raise ActionError("A directory already exists "
 
426
                    + "with that name")
 
427
        else:
 
428
            if os.path.exists(filepath_local):
 
429
                raise ActionError("A file already exists with that name")
422
430
        filedata = datum.file
423
431
 
424
432
        if unpack and datum.filename.lower().endswith(".zip"):
433
441
                zip.unzip(abspath, filedata)
434
442
            except (OSError, IOError):
435
443
                goterror = True
 
444
            except WillNotOverwrite, e:
 
445
                raise ActionError("File '" + e.filename + "' already exists.")
436
446
        else:
437
447
            # Not a zip file
438
448
            (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)