23
23
# This is a command-line application, for use by the administrator.
24
# This program is a frontend for the modules in the setup packages that
25
# build and install IVLE in separate steps.
26
# It is called with at least one argument, which specifies which operation to
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).
37
# Print the opening spiel including the GPL notice
39
print """IVLE - Informatics Virtual Learning Environment Setup
40
Copyright (C) 2007-2009 The University of Melbourne
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, "www/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
41
65
IVLE comes with ABSOLUTELY NO WARRANTY.
42
66
This is free software, and you are welcome to redistribute it
43
67
under certain conditions. See LICENSE.txt for details.
48
# First argument is the name of the setup operation
52
# Print usage message and exit
56
oper_func = call_operator(operation)
57
return oper_func(argv[2:])
61
print """Usage: python setup.py operation [options]
67
For help and options for a specific operation use 'help [operation]'."""
70
oper_func = call_operator(operator)
71
oper_func(['operator','--help'])
73
def call_operator(operation):
74
# Call the requested operation's function
78
'build' : setup.build.build,
79
'install' : setup.install.install,
83
"""Invalid operation '%s'. Try python setup.py help."""
88
if __name__ == "__main__":
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"