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

« back to all changes in this revision

Viewing changes to ivle/console.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:
32
32
 
33
33
import cjson
34
34
 
 
35
import ivle.conf
35
36
from ivle import chat
36
37
 
 
38
# Outside Jail
 
39
trampoline_path = os.path.join(ivle.conf.lib_path, "trampoline")
 
40
# Inside Jail
 
41
python_path = "/usr/bin/python"
 
42
console_dir = os.path.join(ivle.conf.share_path, 'services')
 
43
console_path = os.path.join(console_dir, 'python-console')
 
44
 
37
45
class ConsoleError(Exception):
38
46
    """ The console failed in some way. This is bad. """
39
47
    def __init__(self, value):
114
122
class Console(object):
115
123
    """ Provides a nice python interface to the console
116
124
    """
117
 
    def __init__(self, config, uid, jail_path, working_dir):
 
125
    def __init__(self, uid, jail_path, working_dir):
118
126
        """Starts up a console service for user uid, inside chroot jail 
119
127
        jail_path with work directory of working_dir
120
128
        """
121
129
        super(Console, self).__init__()
122
130
 
123
 
        self.config = config
124
131
        self.uid = uid
125
132
        self.jail_path = jail_path
126
133
        self.working_dir = working_dir
161
168
        while tries < 5:
162
169
            self.port = int(random.uniform(3000, 8000))
163
170
 
164
 
            trampoline_path = os.path.join(self.config['paths']['lib'],
165
 
                                           "trampoline")
166
 
 
167
171
            # Start the console server (port, magic)
168
172
            # trampoline usage: tramp uid jail_dir working_dir script_path args
169
173
            # console usage:    python-console port magic
170
174
            res = os.spawnv(os.P_WAIT, trampoline_path, [
171
175
                trampoline_path,
172
176
                str(self.uid),
173
 
                self.config['paths']['jails']['mounts'],
174
 
                self.config['paths']['jails']['src'],
175
 
                self.config['paths']['jails']['template'],
 
177
                ivle.conf.jail_base,
 
178
                ivle.conf.jail_src_base,
 
179
                ivle.conf.jail_system,
176
180
                self.jail_path,
177
 
                os.path.join(self.config['paths']['share'], 'services'),
178
 
                "/usr/bin/python",
179
 
                os.path.join(self.config['paths']['share'],
180
 
                             'services/python-console'),
 
181
                console_dir,
 
182
                python_path,
 
183
                console_path,
181
184
                str(self.port),
182
185
                str(self.magic),
183
186
                self.working_dir
297
300
              
298
301
        # Unpickle any exceptions
299
302
        if 'exception' in execute:
300
 
            execute['exception'] = cPickle.loads(execute['exception'])
301
 
        return execute
 
303
            return cPickle.loads(execute['exception'])
 
304
        else:
 
305
            return execute
302
306
 
303
307
 
304
308
    def set_vars(self, variables):