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

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: mattgiuca
  • Date: 2007-12-20 03:59:50 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:97
Moved template.py and setup.py to better places.
www/common/interpret.py:
    * Uses bin/trampoline (the C compiled version)
    * Uses ivle_install_dir instead of the web path (ivlepath).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
# Date:   12/12/2007
22
22
 
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
27
 
# take.
 
24
# Prompts the administrator to enter machine-specific details and builds the
 
25
# file conf/conf.py.
 
26
# (This file is not included with the distribution precisely because it
 
27
# contains machine-specific settings).
28
28
 
 
29
import os
29
30
import sys
30
 
import setup.build
31
 
import setup.install
32
 
 
33
 
def main(argv=None):
34
 
    if argv is None:
35
 
        argv = sys.argv
36
 
 
37
 
    # Print the opening spiel including the GPL notice
38
 
 
39
 
    print """IVLE - Informatics Virtual Learning Environment Setup
40
 
Copyright (C) 2007-2009 The University of Melbourne
 
31
 
 
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.
 
36
    """
 
37
    sys.stdout.write(prompt)
 
38
    sys.stdout.write("\n>")
 
39
    try:
 
40
        val = sys.stdin.readline()
 
41
    except KeyboardInterrupt:
 
42
        # Ctrl+C
 
43
        sys.stdout.write("\n")
 
44
        sys.exit(1)
 
45
    sys.stdout.write("\n")
 
46
    if val == '': sys.exit(1)
 
47
    return val.strip()
 
48
 
 
49
# MAIN SCRIPT
 
50
 
 
51
# Set up some variables
 
52
 
 
53
cwd = os.getcwd()
 
54
# conffile is the file that will be created/overwritten
 
55
conffile = os.path.join(cwd, "www/conf/conf.py")
 
56
 
 
57
# Fixed config options that we don't ask the admin
 
58
 
 
59
default_app = "dummy"
 
60
 
 
61
# Print the opening spiel including the GPL notice
 
62
 
 
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.
44
 
 
45
 
IVLE Setup
46
 
"""
47
 
 
48
 
    # First argument is the name of the setup operation
49
 
    try:
50
 
        operation = argv[1]
51
 
    except IndexError:
52
 
        # Print usage message and exit
53
 
        help([])
54
 
        return 1
55
 
 
56
 
    oper_func = call_operator(operation)
57
 
    return oper_func(argv[2:])
58
 
 
59
 
def help(args):
60
 
    if len(args)!=1:
61
 
        print """Usage: python setup.py operation [options]
62
 
Operation can be:
63
 
    help [operation]
64
 
    build
65
 
    install
66
 
 
67
 
    For help and options for a specific operation use 'help [operation]'."""
68
 
    else:
69
 
        operator = args[0]
70
 
        oper_func = call_operator(operator)
71
 
        oper_func(['operator','--help'])
72
 
 
73
 
def call_operator(operation):
74
 
    # Call the requested operation's function
75
 
    try:
76
 
        oper_func = {
77
 
            'help' : help,
78
 
            'build' : setup.build.build,
79
 
            'install' : setup.install.install,
80
 
        }[operation]
81
 
    except KeyError:
82
 
        print >>sys.stderr, (
83
 
            """Invalid operation '%s'. Try python setup.py help."""
84
 
            % operation)
85
 
        sys.exit(1)
86
 
    return oper_func
87
 
 
88
 
if __name__ == "__main__":
89
 
    sys.exit(main())
 
68
"""
 
69
 
 
70
print """IVLE Setup
 
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.
 
74
 
 
75
Please hit Ctrl+C now if you do not wish to do this.
 
76
"""
 
77
 
 
78
# Get information from the administrator
 
79
# If EOF is encountered at any time during the questioning, just exit silently
 
80
 
 
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")""")
 
86
 
 
87
# Write conf.py
 
88
 
 
89
try:
 
90
    conf = open(conffile, "w")
 
91
 
 
92
    conf.write("""# IVLE Configuration File
 
93
# conf.py
 
94
# Miscellaneous application settings
 
95
 
 
96
 
 
97
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
 
98
# with this).
 
99
# eg. "/" or "/ivle".
 
100
root_dir = """ + '"' + root_dir + '"' + """
 
101
 
 
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
 
104
# this location.
 
105
student_dir = """ + '"' + student_dir + '"' + """
 
106
 
 
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 + '"' + """
 
112
""")
 
113
    
 
114
    conf.close()
 
115
except IOError, (errno, strerror):
 
116
    print "IO error(%s): %s" % (errno, strerror)
 
117
    sys.exit(1)
 
118
 
 
119
print "Successfully wrote conf.py"
 
120
print
 
121
print "You may modify the configuration at any time by editing"
 
122
print conffile
 
123
print
90
124