23
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).
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
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
# the files that will be created/overwritten
55
conffile = os.path.join(cwd, "www/conf/conf.py")
56
conf_hfile = os.path.join(cwd, "trampoline/conf.h")
58
# Fixed config options that we don't ask the admin
62
# Print the opening spiel including the GPL notice
64
print """IVLE - Informatics Virtual Learning Environment Setup
65
Copyright (C) 2007-2008 The University of Melbourne
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
66
41
IVLE comes with ABSOLUTELY NO WARRANTY.
67
42
This is free software, and you are welcome to redistribute it
68
43
under certain conditions. See LICENSE.txt for details.
72
This tool will create the following files:
75
prompting you for details about your configuration. The file will be
76
overwritten if it already exists. It will *not* install or deploy IVLE.
78
Please hit Ctrl+C now if you do not wish to do this.
79
""" % (conffile, conf_hfile)
81
# Get information from the administrator
82
# If EOF is encountered at any time during the questioning, just exit silently
84
root_dir = query_user("""Root directory where IVLE is located (in URL space):
85
(eg. "/" or "/ivle")""")
86
ivle_install_dir = query_user('Root directory where IVLE is located (on the '
87
'local file system):\n'
88
'(eg. "/home/informatics/ivle")')
89
student_dir = query_user(
90
"""Root directory where user files are stored (on the local file system):
91
(eg. "/home/informatics/jails")""")
96
conf = open(conffile, "w")
98
conf.write("""# IVLE Configuration File
100
# Miscellaneous application settings
103
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
105
# eg. "/" or "/ivle".
108
# In the local file system, where IVLE is actually installed.
109
# This directory should contain the "www" and "bin" directories.
110
ivle_install_dir = "%s"
112
# In the local file system, where are the student/user file spaces located.
113
# The user jails are expected to be located immediately in subdirectories of
117
# Which application to load by default (if the user navigates to the top level
118
# of the site). This is the app's URL name.
119
# Note that if this app requires authentication, the user will first be
120
# presented with the login screen.
122
""" % (root_dir, ivle_install_dir, student_dir, default_app))
125
except IOError, (errno, strerror):
126
print "IO error(%s): %s" % (errno, strerror)
129
print "Successfully wrote www/conf.py"
131
# Write trampoline/conf.h
134
conf = open(conf_hfile, "w")
136
conf.write("""/* IVLE Configuration File
138
* Administrator settings required by trampoline.
139
* Note: trampoline will have to be rebuilt in order for changes to this file
143
/* In the local file system, where are the jails located.
144
* The trampoline does not allow the creation of a jail anywhere besides
145
* jail_base or a subdirectory of jail_base.
147
static const char* jail_base = "%s";
151
except IOError, (errno, strerror):
152
print "IO error(%s): %s" % (errno, strerror)
155
print "Successfully wrote trampoline/conf.h"
158
print "You may modify the configuration at any time by editing"
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__":