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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-07-05 05:55:33 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090705055533-9gs58527qs6u4zi0
Add a new root breadcrumb image, and a pathetic breadcrumb chevron.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
        # Start the server
53
53
        jail_path = os.path.join(req.config['paths']['jails']['mounts'],
54
54
                                 req.user.login)
55
 
        cons = ivle.console.Console(uid, jail_path, working_dir)
 
55
        cons = ivle.console.Console(req.config, uid, jail_path, working_dir)
56
56
 
57
57
        # Assemble the key and return it. Yes, it is double-encoded.
58
58
        return {'key': cjson.encode({"host": cons.host,
81
81
        working_dir = os.path.join("/home", req.user.login)   # Within jail
82
82
        uid = req.user.unixid
83
83
 
 
84
        # XXX: JSONRESTView should do this for us.
 
85
        text = text.decode('utf-8')
 
86
 
84
87
        msg = {'cmd':kind, 'text':text}
85
88
        try:
86
89
            json_response = ivle.chat.chat(host, port, msg, magic,decode=False)
93
96
                response = {"terminate":
94
97
                    "Communication to console process lost"}
95
98
            if "terminate" in response:
96
 
                response = restart_console(uid, jail_path, working_dir,
97
 
                    response["terminate"])
 
99
                response = restart_console(req.config, uid, jail_path,
 
100
                    working_dir, response["terminate"])
98
101
        except socket.error, (enumber, estring):
99
102
            if enumber == errno.ECONNREFUSED:
100
103
                # Timeout: Restart the session
101
 
                response = restart_console(uid, jail_path, working_dir,
 
104
                response = restart_console(req.config, uid, jail_path,
 
105
                    working_dir,
102
106
                    "The IVLE console has timed out due to inactivity")
103
107
            elif enumber == errno.ECONNRESET:
104
108
                # Communication issue: Restart the session
105
 
                response = restart_console(uid, jail_path, working_dir,
 
109
                response = restart_console(req.config, uid, jail_path,
 
110
                    working_dir,
106
111
                    "Connection with the console has been reset")
107
112
            else:
108
113
                # Some other error - probably serious
110
115
        return response
111
116
 
112
117
 
113
 
def restart_console(uid, jail_path, working_dir, reason):
 
118
def restart_console(config, uid, jail_path, working_dir, reason):
114
119
    """Tells the client that it must be issued a new console since the old 
115
120
    console is no longer availible. The client must accept the new key.
116
121
    Returns the JSON response to be given to the client.
117
122
    """
118
123
    # Start a new console server console
119
 
    cons = ivle.console.Console(uid, jail_path, working_dir)
 
124
    cons = ivle.console.Console(config, uid, jail_path, working_dir)
120
125
 
121
126
    # Make a JSON object to tell the browser to restart its console client
122
127
    new_key = cjson.encode(