1092.1.11
by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using |
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 |
conffile = search_conffile() |
|
50 |
conf = configobj.ConfigObj(conffile) |
|
51 |
||
52 |
CONFIG_OPTIONS = ('root_dir', 'prefix', 'data_path', 'log_path', |
|
53 |
'public_host', 'allowed_uids', 'db_host', 'db_port', 'db_dbname', |
|
54 |
'db_forumdbname', 'db_user', 'db_password', 'auth_modules', 'ldap_url', |
|
55 |
'ldap_format_string', 'subject_pulldown_modules', 'svn_addr', |
|
56 |
'usrmgt_host', 'usrmgt_port', 'usrmgt_magic', 'forum_secret' |
|
57 |
)
|
|
58 |
||
59 |
for opt in CONFIG_OPTIONS: |
|
60 |
globals()[opt] = conf[opt] |
|
61 |
||
62 |
# XXX Convert db_port and usrmgt_port to int.
|
|
63 |
# Because.
|
|
64 |
db_port = int(db_port) |
|
65 |
usrmgt_port = int(usrmgt_port) |
|
66 |
||
67 |
# Additional auto-generated config options
|
|
68 |
||
69 |
# Path where architecture-dependent data (including non-user-executable
|
|
70 |
# binaries) is installed.
|
|
71 |
lib_path = os.path.join(prefix, 'lib/ivle') |
|
72 |
||
73 |
# Path where arch-independent data is installed.
|
|
74 |
share_path = os.path.join(prefix, 'share/ivle') |
|
75 |
||
76 |
# Path where user-executable binaries are installed.
|
|
77 |
bin_path = os.path.join(prefix, 'bin') |
|
78 |
||
79 |
# 'site-packages' directory in Python, where Python libraries are to be
|
|
80 |
# installed.
|
|
81 |
PYTHON_VERSION = sys.version[0:3] # eg. "2.5" |
|
82 |
python_site_packages = os.path.join(prefix, |
|
83 |
'lib/python%s/site-packages' % PYTHON_VERSION) |
|
84 |
||
85 |
# In the local file system, where the student/user jails will be mounted.
|
|
86 |
# Only a single copy of the jail's system components will be stored here -
|
|
87 |
# all user jails will be virtually mounted here.
|
|
88 |
jail_base = os.path.join(data_path, 'jailmounts') |
|
89 |
||
90 |
# In the local file system, where are the student/user file spaces located.
|
|
91 |
# The user jails are expected to be located immediately in subdirectories of
|
|
92 |
# this location. Note that no complete jails reside here - only user
|
|
93 |
# modifications.
|
|
94 |
jail_src_base = os.path.join(data_path, 'jails') |
|
95 |
||
96 |
# In the local file system, where the template system jail will be stored.
|
|
97 |
jail_system = os.path.join(jail_src_base, '__base__') |
|
98 |
||
99 |
# In the local file system, where the template system jail will be stored.
|
|
100 |
jail_system_build = os.path.join(jail_src_base, '__base_build__') |
|
101 |
||
102 |
# In the local file system, where the subject content files are located.
|
|
103 |
# (The 'subjects' and 'exercises' directories).
|
|
104 |
content_path = os.path.join(data_path, 'content') |
|
105 |
||
106 |
# In the local file system, where are the per-subject file spaces located.
|
|
107 |
# The individual subject directories are expected to be located immediately
|
|
108 |
# in subdirectories of this location.
|
|
109 |
subjects_base = os.path.join(content_path, 'subjects') |
|
110 |
||
111 |
# In the local file system, where are the subject-independent exercise sheet
|
|
112 |
# file spaces located.
|
|
113 |
exercises_base = os.path.join(content_path, 'exercises') |
|
114 |
||
115 |
# In the local file system, where the system notices are stored (such as terms
|
|
116 |
# of service and MOTD).
|
|
117 |
notices_path = os.path.join(data_path, 'notices') |
|
118 |
||
119 |
# In the local file system, where is the Terms of Service document located.
|
|
120 |
tos_path = os.path.join(notices_path, 'tos.html') |
|
121 |
||
122 |
# In the local file system, where is the Message of the Day document
|
|
123 |
# located. This is an HTML file (just the body fragment), which will
|
|
124 |
# be displayed on the login page. It is optional.
|
|
125 |
motd_path = os.path.join(notices_path, 'motd.html') |
|
126 |
||
127 |
# The location of all the subversion config and repositories.
|
|
128 |
svn_path = os.path.join(data_path, 'svn') |
|
129 |
||
130 |
# The location of the subversion configuration file used by
|
|
131 |
# apache to host the user repositories.
|
|
132 |
svn_conf = os.path.join(svn_path, 'svn.conf') |
|
133 |
||
134 |
# The location of the subversion configuration file used by
|
|
135 |
# apache to host the user repositories.
|
|
136 |
svn_group_conf = os.path.join(svn_path, 'svn-group.conf') |
|
137 |
||
138 |
# The root directory for the subversion repositories.
|
|
139 |
svn_repo_path = os.path.join(svn_path, 'repositories') |
|
140 |
||
141 |
# The location of the password file used to authenticate users
|
|
142 |
# of the subversion repository from the ivle server.
|
|
143 |
svn_auth_ivle = os.path.join(svn_path, 'ivle.auth') |