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

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
1092.1.14 by Matt Giuca
Added module ivle.config, which takes care of some work interfacing with
32
import ivle.config
1092.1.11 by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using
33
1092.1.12 by Matt Giuca
Changed new-style config file to a hierarchical one with nice shiny new names.
34
try:
1092.1.59 by William Grant
Move the plugin loading/indexing logic into ivle.config.Config.
35
    conf = ivle.config.Config(plugins=False)
1092.1.14 by Matt Giuca
Added module ivle.config, which takes care of some work interfacing with
36
except ivle.config.ConfigError, e:
1092.1.12 by Matt Giuca
Changed new-style config file to a hierarchical one with nice shiny new names.
37
    raise ImportError(str(e))
38
39
# This dict maps legacy config option names to new config option paths
40
# ('section/option_name')
41
CONFIG_OPTIONS = {
42
    'root_dir': 'urls/root',
43
    'prefix': 'paths/prefix',
44
    'data_path': 'paths/data',
45
    'log_path': 'paths/logs',
46
    'python_site_packages_override': 'paths/site_packages',
47
    'public_host': 'urls/public_host',
48
    'db_host': 'database/host',
49
    'db_port': 'database/port',
50
    'db_dbname': 'database/name',
51
    'db_user': 'database/username',
52
    'db_password': 'database/password',
53
    'auth_modules': 'auth/modules',
54
    'ldap_url': 'auth/ldap_url',
55
    'ldap_format_string': 'auth/ldap_format_string',
56
    'subject_pulldown_modules': 'auth/subject_pulldown_modules',
57
    'svn_addr': 'urls/svn_addr',
58
    'usrmgt_host': 'usrmgt/host',
59
    'usrmgt_port': 'usrmgt/port',
60
    'usrmgt_magic': 'usrmgt/magic',
61
}
62
63
for legacyopt, newopt_path in CONFIG_OPTIONS.iteritems():
64
    # Iterate over each segment of the path, and find the value in conf file
65
    try:
66
        value = conf
67
        for seg in newopt_path.split('/'):
68
            value = value[seg]
69
        globals()[legacyopt] = value
70
    except KeyError:
71
        globals()[legacyopt] = None
72
73
# XXX Munge some nice shiny new-style values into horrible old-style values
74
# IRONY: These have just been split from commas. We need to re-join it so that
75
# pulldown_subj and auth_modules can re-split them.
76
subject_pulldown_modules = ','.join(subject_pulldown_modules)
77
auth_modules = ','.join(auth_modules)
1092.1.11 by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using
78
79
# Additional auto-generated config options
80
81
# Path where architecture-dependent data (including non-user-executable
82
# binaries) is installed.
83
lib_path = os.path.join(prefix, 'lib/ivle')
84
85
# Path where arch-independent data is installed.
86
share_path = os.path.join(prefix, 'share/ivle')
87
88
# Path where user-executable binaries are installed.
89
bin_path = os.path.join(prefix, 'bin')
90
91
# 'site-packages' directory in Python, where Python libraries are to be
92
# installed.
1092.1.12 by Matt Giuca
Changed new-style config file to a hierarchical one with nice shiny new names.
93
if python_site_packages_override is None:
94
    PYTHON_VERSION = sys.version[0:3]   # eg. "2.5"
95
    python_site_packages = os.path.join(prefix,
96
                               'lib/python%s/site-packages' % PYTHON_VERSION)
97
else:
98
    python_site_packages = python_site_packages_override
1092.1.11 by Matt Giuca
Replaced Python config files (conf.py) with new config files system, using
99
100
# In the local file system, where the student/user jails will be mounted.
101
# Only a single copy of the jail's system components will be stored here -
102
# all user jails will be virtually mounted here.
103
jail_base = os.path.join(data_path, 'jailmounts')
104
105
# In the local file system, where are the student/user file spaces located.
106
# The user jails are expected to be located immediately in subdirectories of
107
# this location. Note that no complete jails reside here - only user
108
# modifications.
109
jail_src_base = os.path.join(data_path, 'jails')
110
111
# In the local file system, where the template system jail will be stored.
112
jail_system = os.path.join(jail_src_base, '__base__')
113
114
# In the local file system, where the template system jail will be stored.
115
jail_system_build = os.path.join(jail_src_base, '__base_build__')
116
117
# In the local file system, where the subject content files are located.
118
# (The 'subjects' and 'exercises' directories).
119
content_path = os.path.join(data_path, 'content')
120
121
# In the local file system, where are the per-subject file spaces located.
122
# The individual subject directories are expected to be located immediately
123
# in subdirectories of this location.
124
subjects_base = os.path.join(content_path, 'subjects')
125
126
# In the local file system, where are the subject-independent exercise sheet
127
# file spaces located.
128
exercises_base = os.path.join(content_path, 'exercises')
129
130
# In the local file system, where the system notices are stored (such as terms
131
# of service and MOTD).
132
notices_path = os.path.join(data_path, 'notices')
133
134
# In the local file system, where is the Terms of Service document located.
135
tos_path = os.path.join(notices_path, 'tos.html')
136
137
# In the local file system, where is the Message of the Day document
138
# located. This is an HTML file (just the body fragment), which will
139
# be displayed on the login page. It is optional.
140
motd_path = os.path.join(notices_path, 'motd.html')
141
142
# The location of all the subversion config and repositories.
143
svn_path = os.path.join(data_path, 'svn')
144
145
# The location of the subversion configuration file used by
146
# apache to host the user repositories.
147
svn_conf = os.path.join(svn_path, 'svn.conf')
148
149
# The location of the subversion configuration file used by
150
# apache to host the user repositories.
151
svn_group_conf = os.path.join(svn_path, 'svn-group.conf')
152
153
# The root directory for the subversion repositories.
154
svn_repo_path = os.path.join(svn_path, 'repositories')
155
156
# The location of the password file used to authenticate users
157
# of the subversion repository from the ivle server.
158
svn_auth_ivle = os.path.join(svn_path, 'ivle.auth')