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

« back to all changes in this revision

Viewing changes to ivle/interpret.py

  • Committer: William Grant
  • Date: 2009-03-17 04:48:07 UTC
  • mfrom: (1099.1.243 exercise-ui)
  • Revision ID: grantw@unimelb.edu.au-20090317044807-pozdt54fapazp2sp
Merge lp:~ivle-dev/ivle/exercise-ui.

Lecturers can now add and edit exercises, and worksheets can be written
in RST directly inside IVLE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
# Runs a student script in a safe execution environment.
23
23
 
24
24
from ivle import studpath
25
 
from ivle.util import IVLEError, IVLEJailError, split_path
 
25
from ivle.util import IVLEError, IVLEJailError
26
26
import ivle.conf
27
27
 
28
28
import functools
404
404
    if script_path and script_path.startswith('/home'):
405
405
        normscript = os.path.normpath(script_path)
406
406
 
407
 
        uri_into_jail = studpath.to_home_path(os.path.normpath(req.path))
 
407
        uri_into_jail = studpath.url_to_jailpaths(os.path.normpath(req.path))[2]
408
408
 
409
409
        # PATH_INFO is wrong because the script doesn't physically exist.
410
410
        env['PATH_INFO'] = uri_into_jail[len(normscript):]
416
416
    env['SERVER_SOFTWARE'] = "IVLE/" + str(ivle.conf.ivle_version)
417
417
 
418
418
    # Additional environment variables
419
 
    username = split_path(req.path)[0]
 
419
    username = studpath.url_to_jailpaths(req.path)[0]
420
420
    env['HOME'] = os.path.join('/home', username)
421
421
 
422
422
class ExecutionError(Exception):
439
439
         working_dir, binary] + args,
440
440
        stdin=subprocess.PIPE, stdout=subprocess.PIPE,
441
441
        stderr=subprocess.PIPE, cwd=tramp_dir, close_fds=True)
442
 
 
443
 
    (stdout, stderr) = proc.communicate()
444
 
    exitcode = proc.returncode
 
442
    exitcode = proc.wait()
445
443
 
446
444
    if exitcode != 0:
447
445
        raise ExecutionError('subprocess ended with code %d, stderr %s' %
448
446
                             (exitcode, proc.stderr.read()))
449
 
    return (stdout, stderr)
 
447
    return (proc.stdout.read(), proc.stderr.read())