2
# IVLE - Informatics Virtual Learning Environment
3
# Copyright (C) 2007-2008 The University of Melbourne
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
# This is a command-line application, for use by the administrator.
24
# Prompts the administrator to enter machine-specific details and builds the
26
# (This file is not included with the distribution precisely because it
27
# contains machine-specific settings).
32
def query_user(prompt):
33
"""Prompts the user for a string, which is read from a line of stdin.
34
Exits silently if EOF is encountered. Returns the string, with spaces
35
removed from the beginning and end.
37
sys.stdout.write(prompt)
38
sys.stdout.write("\n>")
40
val = sys.stdin.readline()
41
except KeyboardInterrupt:
43
sys.stdout.write("\n")
45
sys.stdout.write("\n")
46
if val == '': sys.exit(1)
51
# Set up some variables
54
# conffile is the file that will be created/overwritten
55
conffile = os.path.join(cwd, "conf/conf.py")
57
# Fixed config options that we don't ask the admin
61
# Print the opening spiel including the GPL notice
63
print """IVLE - Informatics Virtual Learning Environment Setup
64
Copyright (C) 2007-2008 The University of Melbourne
65
IVLE comes with ABSOLUTELY NO WARRANTY.
66
This is free software, and you are welcome to redistribute it
67
under certain conditions. See LICENSE.txt for details.
71
This tool will create the file """ + conffile + """,
72
prompting you for details about your configuration. The file will be
73
overwritten if it already exists. It will *not* install or deploy IVLE.
75
Please hit Ctrl+C now if you do not wish to do this.
78
# Get information from the administrator
79
# If EOF is encountered at any time during the questioning, just exit silently
81
root_dir = query_user("""Root directory where IVLE is located (in URL space):
82
(eg. "/" or "/ivle")""")
83
student_dir = query_user(
84
"""Root directory where user files are stored (on the local file system):
85
(eg. "/home/informatics/jails")""")
90
conf = open(conffile, "w")
92
conf.write("""# IVLE Configuration File
94
# Miscellaneous application settings
97
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
100
root_dir = """ + '"' + root_dir + '"' + """
102
# In the local file system, where are the student/user file spaces located.
103
# The user jails are expected to be located immediately in subdirectories of
105
student_dir = """ + '"' + student_dir + '"' + """
107
# Which application to load by default (if the user navigates to the top level
108
# of the site). This is the app's URL name.
109
# Note that if this app requires authentication, the user will first be
110
# presented with the login screen.
111
default_app = """ + '"' + default_app + '"' + """
115
except IOError, (errno, strerror):
116
print "IO error(%s): %s" % (errno, strerror)
119
print "Successfully wrote conf.py"
121
print "You may modify the configuration at any time by editing"