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

« back to all changes in this revision

Viewing changes to ivle/webapp/console/service.py

  • Committer: David Coles
  • Date: 2010-02-26 10:44:48 UTC
  • Revision ID: coles.david@gmail.com-20100226104448-4d1r3qco3shgn1gk
Tags: 1.0rc2
console: Make sure HOME is set correctly (not always the same as CWD). Also use ivle.interpret.execute_raw rather than duplicating trapoline calling code in ivle.chat

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    def start(self, req, cwd=''):
48
48
        working_dir = os.path.join("/home", req.user.login, cwd)
49
49
 
50
 
        uid = req.user.unixid
51
 
 
52
50
        # Start the server
53
51
        jail_path = os.path.join(req.config['paths']['jails']['mounts'],
54
52
                                 req.user.login)
55
 
        cons = ivle.console.Console(req.config, uid, jail_path, working_dir)
 
53
        cons = ivle.console.Console(req.config, req.user, jail_path,
 
54
                working_dir)
56
55
 
57
56
        # Assemble the key and return it. Yes, it is double-encoded.
58
57
        return {'key': cjson.encode({"host": cons.host,
96
95
                response = {"terminate":
97
96
                    "Communication lost"}
98
97
            if "terminate" in response:
99
 
                response = restart_console(req.config, uid, jail_path,
 
98
                response = restart_console(req.config, req.user, jail_path,
100
99
                    working_dir, response["terminate"])
101
100
        except socket.error, (enumber, estring):
102
101
            if enumber == errno.ECONNREFUSED:
115
114
        return response
116
115
 
117
116
 
118
 
def restart_console(config, uid, jail_path, working_dir, reason):
 
117
def restart_console(config, user, jail_path, working_dir, reason):
119
118
    """Tells the client that it must be issued a new console since the old 
120
119
    console is no longer availible. The client must accept the new key.
121
120
    Returns the JSON response to be given to the client.
122
121
    """
123
122
    # Start a new console server console
124
 
    cons = ivle.console.Console(config, uid, jail_path, working_dir)
 
123
    cons = ivle.console.Console(config, user, jail_path, working_dir)
125
124
 
126
125
    # Make a JSON object to tell the browser to restart its console client
127
126
    new_key = cjson.encode(