2
# Copyright (C) 2007-2008 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
# Author: Matt Giuca, Tom Conway
26
from common import (util, studpath)
30
"""Handler for the Console Service AJAX backend application."""
32
# Set request attributes
33
req.content_type = "text/plain"
34
req.write_html_head_foot = False
36
# TODO: Figure out the host name the console server is running on.
39
# Find an available port on the server.
47
# Start the console server (port, magic)
48
# TODO: Trampoline into the jail, and run it as a background process
49
jail = os.path.join(conf.jail_base, req.username)
50
console_dir = os.path.join(jail, "opt/ivle/console/")
51
console_path = os.path.join(console_dir, "python-console")
52
os.system("cd " + console_dir + "; "
53
+ console_path + " " + str(port) + " " + str(magic)
54
+ " > /home/mgiuca/Desktop/python_console_log 2>&1 &")
57
req.write(cjson.encode({"host": host, "port": port, "magic": magic}))