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

« back to all changes in this revision

Viewing changes to ivle/conf/conf.py

setup.configure: Removed "###" major heading comment generated into ivle.conf
    (no longer needed due to actual headings).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# IVLE - Informatics Virtual Learning Environment
 
2
# Copyright (C) 2007-2009 The University of Melbourne
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
17
 
 
18
# Author: Matt Giuca, Will Grant
 
19
 
 
20
"""
 
21
Temporary emulation layer for the old-style conf.py configuration file.
 
22
Loads the IVLE config file and provides all of the legacy config variables.
 
23
 
 
24
May raise a RuntimeError on import if it cannot find the config file.
 
25
"""
 
26
 
 
27
import os
 
28
import sys
 
29
 
 
30
import configobj
 
31
 
 
32
def search_conffile():
 
33
    """
 
34
    Search for the config file, and return it as a filename.
 
35
    1. Environment var IVLECONF (full filename).
 
36
    2. ./etc/ivle.conf
 
37
    3. /etc/ivle/ivle.conf
 
38
    """
 
39
    if 'IVLECONF' in os.environ:
 
40
        fname = os.environ['IVLECONF']
 
41
        if os.path.exists(fname):
 
42
            return fname
 
43
    if os.path.exists('./etc/ivle.conf'):
 
44
        return './etc/ivle.conf'
 
45
    if os.path.exists('/etc/ivle/ivle.conf'):
 
46
        return '/etc/ivle/ivle.conf'
 
47
    raise RuntimeError("Could not find IVLE config file")
 
48
 
 
49
try:
 
50
    conffile = search_conffile()
 
51
except RuntimeError, e:
 
52
    raise ImportError(str(e))
 
53
 
 
54
conf = configobj.ConfigObj(conffile)
 
55
 
 
56
# This dict maps legacy config option names to new config option paths
 
57
# ('section/option_name')
 
58
CONFIG_OPTIONS = {
 
59
    'root_dir': 'urls/root',
 
60
    'prefix': 'paths/prefix',
 
61
    'data_path': 'paths/data',
 
62
    'log_path': 'paths/logs',
 
63
    'python_site_packages_override': 'paths/site_packages',
 
64
    'public_host': 'urls/public_host',
 
65
    'allowed_uids': 'os/allowed_uids',
 
66
    'db_host': 'database/host',
 
67
    'db_port': 'database/port',
 
68
    'db_dbname': 'database/name',
 
69
    'db_forumdbname': 'plugins/forum/dbname',
 
70
    'db_user': 'database/username',
 
71
    'db_password': 'database/password',
 
72
    'auth_modules': 'auth/modules',
 
73
    'ldap_url': 'auth/ldap_url',
 
74
    'ldap_format_string': 'auth/ldap_format_string',
 
75
    'subject_pulldown_modules': 'auth/subject_pulldown_modules',
 
76
    'svn_addr': 'urls/svn_addr',
 
77
    'usrmgt_host': 'usrmgt/host',
 
78
    'usrmgt_port': 'usrmgt/port',
 
79
    'usrmgt_magic': 'usrmgt/magic',
 
80
    'forum_secret': 'plugins/forum/secret',
 
81
}
 
82
 
 
83
for legacyopt, newopt_path in CONFIG_OPTIONS.iteritems():
 
84
    # Iterate over each segment of the path, and find the value in conf file
 
85
    try:
 
86
        value = conf
 
87
        for seg in newopt_path.split('/'):
 
88
            value = value[seg]
 
89
        globals()[legacyopt] = value
 
90
    except KeyError:
 
91
        globals()[legacyopt] = None
 
92
 
 
93
# XXX Munge some nice shiny new-style values into horrible old-style values
 
94
# IRONY: These have just been split from commas. We need to re-join it so that
 
95
# pulldown_subj and auth_modules can re-split them.
 
96
subject_pulldown_modules = ','.join(subject_pulldown_modules)
 
97
auth_modules = ','.join(auth_modules)
 
98
 
 
99
# XXX Convert db_port and usrmgt_port to int.
 
100
# Because.
 
101
db_port = int(db_port)
 
102
usrmgt_port = int(usrmgt_port)
 
103
 
 
104
# Additional auto-generated config options
 
105
 
 
106
# Path where architecture-dependent data (including non-user-executable
 
107
# binaries) is installed.
 
108
lib_path = os.path.join(prefix, 'lib/ivle')
 
109
 
 
110
# Path where arch-independent data is installed.
 
111
share_path = os.path.join(prefix, 'share/ivle')
 
112
 
 
113
# Path where user-executable binaries are installed.
 
114
bin_path = os.path.join(prefix, 'bin')
 
115
 
 
116
# 'site-packages' directory in Python, where Python libraries are to be
 
117
# installed.
 
118
if python_site_packages_override is None:
 
119
    PYTHON_VERSION = sys.version[0:3]   # eg. "2.5"
 
120
    python_site_packages = os.path.join(prefix,
 
121
                               'lib/python%s/site-packages' % PYTHON_VERSION)
 
122
else:
 
123
    python_site_packages = python_site_packages_override
 
124
 
 
125
# In the local file system, where the student/user jails will be mounted.
 
126
# Only a single copy of the jail's system components will be stored here -
 
127
# all user jails will be virtually mounted here.
 
128
jail_base = os.path.join(data_path, 'jailmounts')
 
129
 
 
130
# In the local file system, where are the student/user file spaces located.
 
131
# The user jails are expected to be located immediately in subdirectories of
 
132
# this location. Note that no complete jails reside here - only user
 
133
# modifications.
 
134
jail_src_base = os.path.join(data_path, 'jails')
 
135
 
 
136
# In the local file system, where the template system jail will be stored.
 
137
jail_system = os.path.join(jail_src_base, '__base__')
 
138
 
 
139
# In the local file system, where the template system jail will be stored.
 
140
jail_system_build = os.path.join(jail_src_base, '__base_build__')
 
141
 
 
142
# In the local file system, where the subject content files are located.
 
143
# (The 'subjects' and 'exercises' directories).
 
144
content_path = os.path.join(data_path, 'content')
 
145
 
 
146
# In the local file system, where are the per-subject file spaces located.
 
147
# The individual subject directories are expected to be located immediately
 
148
# in subdirectories of this location.
 
149
subjects_base = os.path.join(content_path, 'subjects')
 
150
 
 
151
# In the local file system, where are the subject-independent exercise sheet
 
152
# file spaces located.
 
153
exercises_base = os.path.join(content_path, 'exercises')
 
154
 
 
155
# In the local file system, where the system notices are stored (such as terms
 
156
# of service and MOTD).
 
157
notices_path = os.path.join(data_path, 'notices')
 
158
 
 
159
# In the local file system, where is the Terms of Service document located.
 
160
tos_path = os.path.join(notices_path, 'tos.html')
 
161
 
 
162
# In the local file system, where is the Message of the Day document
 
163
# located. This is an HTML file (just the body fragment), which will
 
164
# be displayed on the login page. It is optional.
 
165
motd_path = os.path.join(notices_path, 'motd.html')
 
166
 
 
167
# The location of all the subversion config and repositories.
 
168
svn_path = os.path.join(data_path, 'svn')
 
169
 
 
170
# The location of the subversion configuration file used by
 
171
# apache to host the user repositories.
 
172
svn_conf = os.path.join(svn_path, 'svn.conf')
 
173
 
 
174
# The location of the subversion configuration file used by
 
175
# apache to host the user repositories.
 
176
svn_group_conf = os.path.join(svn_path, 'svn-group.conf')
 
177
 
 
178
# The root directory for the subversion repositories.
 
179
svn_repo_path = os.path.join(svn_path, 'repositories')
 
180
 
 
181
# The location of the password file used to authenticate users
 
182
# of the subversion repository from the ivle server.
 
183
svn_auth_ivle = os.path.join(svn_path, 'ivle.auth')