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

« back to all changes in this revision

Viewing changes to ivle/fileservice_lib/action.py

  • Committer: Matt Giuca
  • Date: 2009-12-01 04:27:58 UTC
  • mfrom: (1164.2.46 sphinx-docs)
  • Revision ID: matt.giuca@gmail.com-20091201042758-wuxd9bdec00c283i
Merged sphinx-docs branch. This adds Sphinx documentation for the entire IVLE system (for system administrators and developers), and removes all of our random old document files (all either irrelevant, or moved into the Sphinx docs nicely). Currently incomplete, but ready to merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
import os
132
132
import cStringIO
133
133
import shutil
 
134
import urllib
134
135
 
135
136
import pysvn
136
137
 
228
229
 
229
230
    Does not mutate req.
230
231
    """
231
 
    (_, _, r) = studpath.url_to_jailpaths(actionpath_to_urlpath(req, path))
 
232
    r = studpath.to_home_path(actionpath_to_urlpath(req, path))
232
233
    if r is None:
233
234
        raise ActionError("Invalid path")
234
235
    return r
420
421
    for datum in data:
421
422
        # Each of the uploaded files
422
423
        filepath = os.path.join(path, datum.filename)
423
 
        (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)
 
424
        filepath_local = studpath.to_home_path(filepath)
424
425
        if os.path.isdir(filepath_local):
425
426
            raise ActionError("A directory already exists "
426
427
                    + "with that name")
436
437
            # filename)
437
438
            try:
438
439
                # First get the entire path (within jail)
439
 
                _, _, abspath = studpath.url_to_jailpaths(path)
 
440
                abspath = studpath.to_home_path(path)
440
441
                abspath = os.path.join(os.sep, abspath)
441
442
                zip.unzip(abspath, filedata)
442
443
            except (OSError, IOError):
445
446
                raise ActionError("File '" + e.filename + "' already exists.")
446
447
        else:
447
448
            # Not a zip file
448
 
            (_, _, filepath_local) = studpath.url_to_jailpaths(filepath)
 
449
            filepath_local = studpath.to_home_path(filepath)
449
450
            if filepath_local is None:
450
451
                raise ActionError("Invalid path")
451
452
 
532
533
    Reads fields: 'path'
533
534
    """
534
535
    paths = fields.getlist('path')
535
 
    user = studpath.url_to_local(req.path)[0]
 
536
    user = util.split_path(req.path)[0]
536
537
    homedir = "/home/%s" % user
537
538
    if len(paths):
538
539
        paths = map(lambda path: actionpath_to_local(req, path), paths)
539
540
    else:
540
 
        paths = [studpath.url_to_jailpaths(req.path)[2]]
 
541
        paths = [studpath.to_home_path(req.path)]
541
542
 
542
543
    # Set all the dirs in home dir world browsable (o+r,o+x)
543
544
    #FIXME: Should really only do those in the direct path not all of the 
567
568
    if len(paths):
568
569
        paths = map(lambda path: actionpath_to_local(req, path), paths)
569
570
    else:
570
 
        paths = [studpath.url_to_jailpaths(req.path)[2]]
 
571
        paths = [studpath.to_home_path(req.path)]
571
572
 
572
573
    try:
573
574
        for path in paths:
664
665
    if len(paths):
665
666
        paths = map(lambda path: actionpath_to_local(req, path), paths)
666
667
    else:
667
 
        paths = [studpath.url_to_jailpaths(req.path)[2]]
 
668
        paths = [studpath.to_home_path(req.path)]
668
669
 
669
670
    try:
670
671
        for path in paths:
713
714
    paths = fields.getlist('path')
714
715
    if len(paths) != 2:
715
716
        raise ActionError("usage: svncheckout url local-path")
716
 
    url = ivle.conf.svn_addr + "/" + paths[0]
 
717
    url = ivle.conf.svn_addr + "/" + urllib.quote(paths[0])
717
718
    local_path = actionpath_to_local(req, str(paths[1]))
718
719
    try:
719
720
        svnclient.callback_get_login = get_login