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

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/action.py

[Uber-commit of holiday work because I lacked a local copy of the branch.]

 ivle.makeuser: Don't use jailconf.py as a header for the in-jail conf.py;
     generate the whole thing using string formatting operators and include
     the template inline.

 ivle.makeuser.make_conf_py: XXX the inclusion of ivle.conf.jail_base in
     the jail. It is simply there to placate ivle.studpath, and needs
     to go before we can entirely remove the in-jail config.

 ivle-buildjail:
   - Add. Converted from setup.buildjail.
   - Build the jail in __base_build__ and rsync it to __base__ when
     done, rather than operating only in ./jail
   - Rename --rebuildjail/-j to --recreate/-r, as the whole script
     is now for jail rebuilding. Also add a warning to the usage string about
     the large volume likely to be downloaded.
   - Check existence before removing trees.
   - Don't copy jailconf.py over conf.py in the jail. Also make
     sure that we remove conf.pyc.

 setup.configure:
   - Stop generating jailconf.py at all.
   - Add a jail_system_build setting, defaulting to __base_build__ next to
     the existing __base__.
   - Don't use an OptionParser before calling the real function, as that
     adds options dynamically.

 setup.install:
   - Add an option (-R) to avoid writing out svn revision info to
     $PREFIX/share/ivle/revision.txt.
   - Remove jail-copying things.
   - Install all services to the host, rather than just usrmgt-server. We do
     this so we can build the jail from the host without the source tree.
   - Shuffle some things, and don't install phpBB3 twice.
   - Add a --root argument, to take an alternate root directory to install
     into (as given to autotools in $DESTDIR).

 setup.build:
   - Allow running as non-root.
   - Take a --no-compile option to not byte-compile Python files.

 setup.util:
   - Include usrmgt-server in the list of services.
   - Add make_install_path(), a wrapper around os.path.join() that ensures
     the second path is relative.
   - Install ivle-buildjail with the other binaries.

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
149
151
    # If we're being asked again, then it means the credentials failed for
150
152
    # some reason and we should just fail. (This is not desirable, but it's
151
153
    # better than being asked an infinite number of times).
152
 
    return (existing_login != "", ivle.conf.login, ivle.conf.svn_pass, True)
 
154
    return (existing_login != "", str(ivle.conf.login),
 
155
                                  str(ivle.conf.svn_pass), True)
153
156
 
154
157
# Make a Subversion client object
155
158
svnclient = pysvn.Client()
399
402
 
400
403
    Reads fields: 'path', 'data' (file upload, multiple), 'unpack'
401
404
    """
402
 
 
403
405
    # Important: Data is "None" if the file submitted is empty.
404
406
    path = fields.getfirst('path')
405
407
    data = fields['data']
418
420
    for datum in data:
419
421
        # Each of the uploaded files
420
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")
421
430
        filedata = datum.file
422
431
 
423
432
        if unpack and datum.filename.lower().endswith(".zip"):
432
441
                zip.unzip(abspath, filedata)
433
442
            except (OSError, IOError):
434
443
                goterror = True
 
444
            except WillNotOverwrite, e:
 
445
                raise ActionError("File '" + e.filename + "' already exists.")
435
446
        else:
436
447
            # Not a zip file
437
448
            (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)