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

« back to all changes in this revision

Viewing changes to ivle/interpret.py

  • Committer: William Grant
  • Date: 2009-05-26 03:06:53 UTC
  • Revision ID: grantw@unimelb.edu.au-20090526030653-axxawt0o5ws4icbt
Remove ivle.conf usage from ivle.studpath.

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
 
25
from ivle.util import IVLEError, IVLEJailError, split_path
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.url_to_jailpaths(os.path.normpath(req.path))[2]
 
407
        uri_into_jail = studpath.to_home_path(os.path.normpath(req.path))
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 = studpath.url_to_jailpaths(req.path)[0]
 
419
    username = split_path(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
 
    exitcode = proc.wait()
 
442
 
 
443
    (stdout, stderr) = proc.communicate()
 
444
    exitcode = proc.returncode
443
445
 
444
446
    if exitcode != 0:
445
447
        raise ExecutionError('subprocess ended with code %d, stderr %s' %
446
448
                             (exitcode, proc.stderr.read()))
447
 
    return (proc.stdout.read(), proc.stderr.read())
 
449
    return (stdout, stderr)