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

« back to all changes in this revision

Viewing changes to src/setup.py

  • Committer: mattgiuca
  • Date: 2007-12-20 03:14:17 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:93
New directory hierarchy.
Renamed src to www.
Added console, trampoline (currently empty).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# IVLE - Informatics Virtual Learning Environment
3
 
# Copyright (C) 2007-2008 The University of Melbourne
4
 
#
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.
9
 
#
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.
14
 
#
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
18
 
 
19
 
# Module: setup
20
 
# Author: Matt Giuca
21
 
# Date:   12/12/2007
22
 
 
23
 
# This is a command-line application, for use by the administrator.
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
 
 
29
 
import os
30
 
import sys
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, "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
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.
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
124